stop! // to prevent mistakingly running everything

					*************************************
					* 		   Appendix Analysis		*
					*************************************
/* 
 
 File Description: this file generates the figures and tables in the appendix of the article
  
 Data file inputs: 
 
 *confed.dta
 *CCES_full.dta
 *CCES_full_county.dta
 *CCES_full_zip.dta
 *CCES_full_fivemiles.dta
 *CCES_full_tenmiles.dta
 *CCES_full_twentymiles.dta
 *CCES_full_fiftymiles.dta
 *CCES_full_seventyfivemiles.dta
 *CCES_full_onehundredmiles.dta
 *VSG_full_fivemiles.dta
 *VSG_full_tenmiles.dta
 *VSG_full_twentymiles.dta
 *VSG_full_fiftymiles.dta
 *VSG_full_seventyfivemiles.dta
 *VSG_full_onehundredmiles.dta
 *2010Census_county_population.dta
 *zipcode_cov.dta
 *2010Census_zip_population.dta
 *CCES_full_county_updated-withdebates.dta
 *CCES_full_zip_updated-withdebates.dta
 *VSG_debates_county.dta
 *VSG_debates_zip.dta
 *CCES_whites_zip.dta
 *CCES_blacks_zip.dta
 *VSG_white_zip.dta
 *VSG_black_zip.dta
 *CCES_full_zip_with_blm.dta
 *CCES_full_county_updated-post2019_with_blm.dta
 *CCES_full_zip_updated-post2019_with_blm.dta
 *FBI_full_county.dta
 *FBI_white_offender_county.dta
 *FBI_full_zip.dta
 *FBI_white_offender_zip.dta
 
 Outputs in draft: 
 
 *Figure A.1: Removal of Confederate Symbols over Time
 *Table A2: Summary Statistics for Outcome Variables in CCES and VSG
 *Table A3: Summary Statistics on Number of Respondents in each of the Distance Bins (Centroid of Zipcode to Symbol Coordinates) 
 *Figure A.2: Statistics on Number of Individuals per Contextual Unit in the CCES
 *Figure A.3: Statistics on Number of Individuals per Contextual Unit in the VSG
 *Table A4: Difference in Means Test for Contextual Units with No Survey Respondents
 *Table A5: Difference in Means Test for Contextual Units With and Without Respondents
 *Table A6: Effect of Public Debates (Active Symbols) for Nov 2014 vs Dec 2015, (CCES)
 *Table A7: Effect of Public Debates (Active Symbols) for Dec 2016 vs July 2017, (VSG)
 *Figure A.4: Leave-One-Out Test for Former Confederate States
 *Table A9: Effect of Removals for Nov 2014 vs Dec 2015, Weighted by Symbols (CCES)
 *Table A10: Effect of Removals for Nov 2014 vs Dec 2015, Weighted by Respondents (CCES)
 *Table A11: Effect of Removals for Nov 2014 vs Dec 2015, Only More than 5 Respondents(CCES)
 *Table A12: Effect of Removals for Nov 2014 vs Dec 2015, Using Median Scores (CCES)
 *Table A13: Effect of Removals for Nov 2014 vs Dec 2015, Additional Controls, CCES
 *Table A14: Effect of Removals for Nov 2014 vs Dec 2015, State-Local, CCES
 *Table A15: Effect of Removals for Dec 2016 vs. July 2017, State-Local, VSG
 *Table A14: Effect of Removals, No. of Symbols/Contextual Unit, CCES
 *Figure A.5: Distance-Based Contextual Units: CCES Nov 2014 vs. Dec 2015
 *Figure A.6: Distance-Based Contextual Units: VSG Dec 2016 vs July 2017
 *Figure A.7: Placebo Test With Other CCES Political Opinion Questions
 *Figure A.8: Nov 2014 vs Dec 2015 Results for Whites and Blacks
 *Figure A.9: Dec 2016 vs. July 2017 Results for Whites and Blacks
 *Figure A.10: Nov 2014 vs. Dec 2015 Results for Whites and Blacks, by Distance 
 *Table A17: Effect of Removals for Nov 2014 vs Dec 2015 (CCES), Additional Control for BLM
 *Table A18: Effect of Removals for Dec 2018 vs Dec 2020 (CCES) (Post-George Floyd)
 *Figure A.11: Raw Parallel Trends: County-level Hate Crime
 *Figure A.12: Raw Parallel Trends: Zipcode-level Hate Crime

 
 Names of output files:

 *figures/figure-a1-appendix.pdf
 *table a2 output files
	*tables/tablea2-cces.txt
	*tables/tablea2-vsg.txt
 *tables/table3.txt
 *figures/figure-2a-appendix.pdf
 *figures/figure-3a-appendix.pdf
 *tableA4.doc 
 *tableA5.doc
 *table a6 output files
	*tables/tableA6-county.txt
	*tables/tableA6-zip.txt
*tablea7.txt
*tablea8.txt
*figures/figure-a4-appendix.pdf
*table a9 output files
	*tables/tablea9-county.txt
	*tables/tablea9-zip.txt
*table a10 output files
	*tables/tablea10-county.txt
	*tables/tablea10-zip.txt
*table a11 output files
	*tables/tablea11-county.txt
	*tables/tablea11-zip.txt
*table a12 output files
	*tables/tablea12-county.txt
	*tables/tablea12-zip.txt
*table a13 output files
	*tables/tablea13-county.txt
	*tables/tablea13-zip.txt
*table a14 output files
	*tables/tablea14-zip-panelA.txt
 	*tables/tablea14-zip-panelB.txt
*tables/tablea15.txt
*tables/tablea16.txt
*figures/figure-a5-appendix.pdf
*figures/figure-a6-appendix.pdf
*figures/figure-a7-appendix.pdf
*figures/figure-a8-appendix.pdf
*figures/figure-a9-appendix.pdf
*figures/figure-a10-appendix.pdf
*table a18 output files
	*tables/tablea18-county.txt
	*tables/tablea18-zip.txt
*figures/figure-a11-appendix.pdf
figures/figure-a12-appendix.pdf

*/


*   set to your own directory

	global main "/Users/replication_package"

* 	preliminaries

	set more off
	set matsize 10000	
	
***************************************************************
* CODE FOR FIGURE A.1: REMOVAL OF CONFEDERATE SYMBOLS OVER TIME
***************************************************************

	use "$main/data/confed.dta", clear

	gen monthly_date_confed = mofd(mdy(Month_Removed, 1, Year_Removed))
	format monthly_date_confed %tm
	assert missing(monthly_date_confed) == missing(Month_Removed, Year_Removed)

	gen standing = . 
	replace standing = 1877 - 1 if Year_Removed == 1880
	replace standing = 1876 - 1 if Year_Removed == 1923
	replace standing = 1875 - 1 if Year_Removed == 1989
	replace standing = 1874 - 1 if Year_Removed == 1993
	replace standing = 1873 - 1 if Year_Removed == 1998
	replace standing = 1872 - 1 if Year_Removed == 2001
	replace standing = 1871 - 1 if Year_Removed == 2005
	replace standing = 1870 - 1 if Year_Removed == 2009
	replace standing = 1869 - 1 if Year_Removed == 2012
	replace standing = 1868 - 1 if Year_Removed == 2013
	replace standing = 1867 - 3 if Year_Removed == 2014
	replace standing = 1864 - 15 if Year_Removed == 2015
	replace standing = 1849 - 16 if Year_Removed == 2016
	replace standing = 1833 - 57 if Year_Removed == 2017
	replace standing = 1776 - 29 if Year_Removed == 2018
	replace standing = 1747 - 7 if Year_Removed == 2019

	twoway scatter standing monthly_date_confed

	*generate a variable for number of removals by year

		egen tag1 = tag(Unique_ID monthly_date_confed)	
		egen distinct1 = total(tag1) if symbol_status=="Removed", by(monthly_date_confed) 

	*graph of removals over time

	#delimit ;
	twoway scatter distinct1 monthly_date_confed, tlabel(2014m1(3)2019m9, angle(45) labsize(vsmall))
	 xtitle("") ytitle("Number of Symbols Removed", size(small) margin(small)) ylabel(0(5)25, labsize(vsmall) nogrid) 
	msize(vsmall vsmall vsmall vsmall) plotregion(fcolor(white)) mcolor(black)
	graphregion(ilcolor(none) fcolor(white)) tline(2014m11, lp(dash) lc(gray))
	 tline(2015m12, lp(dash) lc(gray))
	  tline(2016m12, lp(dash) lc(gray))
	   tline(2017m7, lp(dash) lc(gray))
		tline(2018m12, lp(dash) lc(gray));
	#delimit cr
	graph export "$main/figures/figure-a1-appendix.pdf", replace
	
	*added in some of the labels manually to the figure using the Stata editor (e.g. the survey labels and lines)

	
******************************************************************************
* CODE FOR TABLE A2: SUMMARY STATISTICS FOR OUTCOME VARIABLES IN CCES AND VSG
******************************************************************************
	set more off 
	
	*******************
	*cces county-level
	*******************

	use "$main/data/CCES_full_county.dta", clear
	
	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015	
	
	egen tag = tag(countycode Unique_ID) 
	egen totalmon = total(tag), by(countycode)

	ta totalmon if monthly_date_confed<tm(2015m7)
	*none with zero monuments at the start of June 2015 so don't drop any counties from sammple

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
		
	bysort countycode: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	by countycode: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm religion_important Black_Pop logpop DemVote12, by(state year region countycode pre_post treated did)

	xtset countycode year  
	by countycode, sort: egen obs = count(year)
	drop if obs <2
	drop obs

	quietly eststo cces_county: estpost sum symbolic_index affirm if year==2014, detail
	
	*******************
	*cces zipcode-level
	*******************
	
	use "$main/data/CCES_full_zip.dta", clear

	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
		
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0
	
	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm religion_important percent_black percent_college med_hh_income percent_white logpop, by(zip state year region countycode pre_post treated did)
	
	xtset zip year 
	by zip, sort: egen obs = count(year)
	drop if obs <2
	drop obs
	
	quietly eststo cces_zip: estpost sum symbolic_index affirm if year==2014, detail

	***********************
	*cces zipcode distances
	***********************
	
	local geo_level "fivemiles tenmiles twentymiles fiftymiles seventyfivemiles onehundredmiles" 
	local n_models: word count `geo_level'
	
	forval i=1/`n_models' {

		***************
		* GLOBALS	 *
		***************	
		
		global geo_level `: word `i' of `geo_level''

		use "$main/data/CCES_full_${geo_level}.dta", clear
	
		keep if year == 2014 | year == 2015
		
		egen tag = tag(countycode Unique_ID) 
		egen totalmon = total(tag), by(countycode)

		ta totalmon if monthly_date_confed<tm(2015m7)
		
		*only depends on time
		gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
		
		*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
		*control group: monuments still active after December 2015

		bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
		
		*at least ONE of the monuments removed so label all rows with that zipcode as treated 
		by zip: egen treated = max(removed)
		
		drop if monthly_date_confed<=tm(2014m2)
		gen did = pre_post*treated 
		
		gen logpop = log(pop2010) 
		
		collapse symbolic_index affirm religion_important percent_black percent_college med_hh_income percent_white logpop, by(zip state year region countycode pre_post treated did)
	
		xtset zip year 
		by zip, sort: egen obs = count(year)
		drop if obs <2
		drop obs
		
		quietly eststo cces_$geo_level: estpost sum symbolic_index affirm if year==2014, detail
		
		}	
	
		
		*******************
		*vsg county-level: 
		*******************
		
		use "$main/data/VSG_full_county.dta", clear
		keep if year == 2016 | year == 2017
		
		egen tag = tag(countycode Unique_ID) 
		egen totalmon = total(tag), by(countycode)
		
		ta totalmon if monthly_date_confed<tm(2016m12)
		drop if totalmon==0
		
		*only depends on time
		gen byte pre_post= monthly_date_vsg == tm(2017m7) if !missing(monthly_date_vsg)
		
		*treatment period group: monuments removed after December 2016 for 2016 VSG and before July 2017 for 2017 VSG
		*control group: monuments still active after July 2017

		bysort countycode: gen byte removed = inrange(monthly_date_confed, tm(2017m1), tm(2017m7))
		by countycode: egen treated = max(removed)

		drop if monthly_date_confed<=tm(2016m12)

		*also collapsing 
		gen did = pre_post*treated 

		*create a line by zipcode year treatment status
		collapse ft_blacks age race liberal conserv educ male, by(id state countycode year pre_post treated did)
				
		gen age2 = age*age
		
		* without any controls yet
		xtset id year
		by id, sort: egen obs = count(year)
			drop if obs <2
			drop obs
		
		quietly eststo vsg_county: estpost sum ft_blacks if year==2016, detail
		
		*******************
		*vsg zipcode-level: 
		*******************
		
		use "$main/data/VSG_full_zip.dta", clear
		keep if year == 2016 | year == 2017
		
		egen tag = tag(zip Unique_ID) 
		egen totalmon = total(tag), by(zip)
		
		ta totalmon if monthly_date_confed<tm(2016m12)
		drop if totalmon==0

		*only depends on time
		gen byte pre_post= monthly_date_vsg == tm(2017m7) if !missing(monthly_date_vsg)
		
		bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2017m1), tm(2017m7))
		by zip: egen treated = max(removed)

		drop if monthly_date_confed<=tm(2016m12) 
		*also collapsing 
		gen did = pre_post*treated 
		
		*create a line by zipcode year treatment status
		collapse ft_blacks age race liberal conserv educ male, by(id zip state countycode year pre_post treated did)
		
		gen age2 = age*age

		xtset id year 
		by id, sort: egen obs = count(year)
			drop if obs <2
			drop obs

		quietly eststo vsg_zip: estpost sum ft_blacks if year==2016, detail
		
		***********************
		*vsg zipcode distances
		***********************
	
		local geo_level "fivemiles tenmiles twentymiles fiftymiles seventyfivemiles onehundredmiles" 
		local n_models: word count `geo_level'
		
		forval i=1/`n_models' {

		***************
		* GLOBALS	 *
		***************	
		
		global geo_level `: word `i' of `geo_level''

		use "$main/data/VSG_full_${geo_level}.dta", clear
	
		keep if year == 2016 | year == 2017
	
		egen tag = tag(zip Unique_ID) 
		egen totalmon = total(tag), by(zip)
		
		ta totalmon if monthly_date_confed<tm(2016m12)
		drop if totalmon==0

		*only depends on time
		gen byte pre_post= monthly_date_vsg == tm(2017m7) if !missing(monthly_date_vsg)
		
		bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2017m1), tm(2017m7))
		by zip: egen treated = max(removed)

		drop if monthly_date_confed<=tm(2016m12) 
		*also collapsing 
		gen did = pre_post*treated 
		
		*create a line by zipcode year treatment status
		collapse ft_blacks age race liberal conserv educ male, by(id zip state countycode year pre_post treated did)
		
		gen age2 = age*age

		xtset id year 
		by id, sort: egen obs = count(year)
			drop if obs <2
			drop obs

		quietly eststo vsg_$geo_level: estpost sum ft_blacks if year==2016, detail
		
	}	
	
		*output for Table A2 (first is CCES and second is VSG)
		esttab cces_county cces_zip cces_fivemiles cces_tenmiles cces_twentymiles cces_fiftymiles cces_seventyfivemiles cces_onehundredmiles using "$main/Tables/tablea2-cces.txt", cells("count mean sd min max") replace
		esttab vsg_county vsg_zip vsg_fivemiles vsg_tenmiles vsg_twentymiles vsg_fiftymiles vsg_seventyfivemiles vsg_onehundredmiles using "$main/Tables/tablea2-vsg.txt", cells("count mean sd min max") replace
	
		*note that in the output of these tables, column (1) is for the county-level, (2) zipcode, (3) 5Mi, (4) 10Mi, (5) 20Mi, (6) 50Mi, (7) 75Mi and (8) 100Mi
		*these output were manually formatted in Latex for the paper
	
	
*************************************************************************************
* CODE FOR TABLE A3: SUMMARY STATISTICS ON NUMBER OF RESPONDENTS IN EACH DISTANCE BIN
*************************************************************************************
	
	*5 MILES, CCES 
	use "$main/data/CCES_full_fivemiles.dta", clear
	keep if year == 2014 | year == 2015

	egen tag1 = tag(id zip)
	*tag unique ids by countycode for each year
	
    egen cces2014_5mi = total(tag1) if year==2014, by(zip) 
	egen cces2015_5mi = total(tag1) if year==2015, by(zip) 

	quietly eststo cces_5mi2014: estpost sum cces2014_5mi, detail 
	*2014: median = 6; mean =  6.342627, sd = 3.47626, obs=12,410; min=1, max=19
	quietly eststo cces_5mi2015: estpost sum cces2015_5mi, detail
	*2015: median = 2; mean = 2.356137, sd=1.416558,  obs= 2,982; min=1, max=8
	
	*10 MILES, CCES 
	use "$main/data/CCES_full_tenmiles.dta", clear
	keep if year == 2014 | year == 2015
	
	egen tag1 = tag(id zip)
	*tag unique ids by countycode for each year
	
    egen cces2014_10mi = total(tag1) if year==2014, by(zip) 
	egen cces2015_10mi = total(tag1) if year==2015, by(zip) 

	quietly eststo cces_10mi2014: estpost sum cces2014_10mi, detail 
	*2014: median = 6; mean =  6.641699, sd =  3.457162, obs=28,998; min=1, max=19
	quietly eststo cces_10mi2015: estpost sum cces2015_10mi, detail
	*2015: median = 2; mean = 2.381086, sd= 1.39247,  obs= 6,757; min=1, max=8
		
	*20 MILES, CCES 
	use "$main/data/CCES_full_twentymiles.dta", clear
	keep if year == 2014 | year == 2015
	
	egen tag1 = tag(id zip)
	*tag unique ids by countycode for each year
	
    egen cces2014_20mi = total(tag1) if year==2014, by(zip) 
	egen cces2015_20mi = total(tag1) if year==2015, by(zip) 

	quietly eststo cces_20mi2014: estpost sum cces2014_20mi, detail 
	*2014: median = 6; mean =  6.730285, sd =   3.589131, obs=54,413; min=1, max=21
	quietly eststo cces_20mi2015: estpost sum cces2015_20mi, detail
	*2015: median = 2; mean =2.311856, sd= 1.352568,  obs= 12,416; min=1, max=8
	
	*50 MILES, CCES
	use "$main/data/CCES_full_fiftymiles.dta", clear
	keep if year == 2014 | year == 2015
	
	egen tag1 = tag(id zip)
	*tag unique ids by countycode for each year
	
    egen cces2014_50mi = total(tag1) if year==2014, by(zip) 
	egen cces2015_50mi = total(tag1) if year==2015, by(zip) 

	quietly eststo cces_50mi2014: estpost sum cces2014_50mi, detail 
	*2014: median = 6; mean =  6.642723, sd =   3.693447, obs=74,939; min=1, max=24
	quietly eststo cces_50mi2015: estpost sum cces2015_50mi, detail
	*2015: median = 2; mean =2.328798, sd=  1.369209,  obs= 17,199; min=1, max=8
	
	*75 MILES, CCES 
	use "$main/data/CCES_full_seventyfivemiles.dta", clear
	keep if year == 2014 | year == 2015
	
	egen tag1 = tag(id zip)
	*tag unique ids by countycode for each year
	
    egen cces2014_75mi = total(tag1) if year==2014, by(zip) 
	egen cces2015_75mi = total(tag1) if year==2015, by(zip) 

	quietly eststo cces_75mi2014: estpost sum cces2014_75mi, detail 
	*2014: median = 6; mean =  6.649649, sd =   3.725901, obs= 76,272; min=1, max=24
	quietly eststo cces_75mi2015: estpost sum cces2015_75mi, detail
	*2015: median = 2; mean = 2.32934, sd=   1.368238,  obs= 17,529; min=1, max=8

	*100 MILES, CCES
	use "$main/data/CCES_full_onehundredmiles.dta", clear
	keep if year == 2014 | year == 2015
	
	egen tag1 = tag(id zip)
	*tag unique ids by countycode for each year
	
    egen cces2014_100mi = total(tag1) if year==2014, by(zip) 
	egen cces2015_100mi = total(tag1) if year==2015, by(zip) 

	quietly eststo cces_100mi2014: estpost sum cces2014_100mi, detail 
	*2014: median = 6; mean =  6.648661, sd =  3.72396, obs=  76,496; min=1, max=24
	quietly eststo cces_100mi2015: estpost sum cces2015_100mi, detail
	*2015: median = 2; mean =  2.329998, sd=   1.369226,  obs= 17,591; min=1, max=8

	*output for Table A3
	esttab cces_5mi2014 using "$main/tables/tablea3.txt", cells("mean sd p50 min max") stats(none) replace
	esttab cces_5mi2015 using "$main/tables/tablea3.txt", cells("mean sd p50 min max") stats(none) append
	esttab cces_10mi2014 using "$main/tables/tablea3.txt", cells("mean sd p50 min max") stats(none) append
	esttab cces_10mi2015 using "$main/tables/tablea3.txt", cells("mean sd p50 min max") stats(none) append
	esttab cces_20mi2014 using "$main/tables/tablea3.txt", cells("mean sd p50 min max") stats(none) append
	esttab cces_20mi2015 using "$main/tables/tablea3.txt", cells("mean sd p50 min max") stats(none) append
	esttab cces_50mi2014 using "$main/tables/tablea3.txt", cells("mean sd p50 min max") stats(none) append
	esttab cces_50mi2015 using "$main/tables/tablea3.txt", cells("mean sd p50 min max") stats(none) append
	esttab cces_75mi2014 using "$main/tables/tablea3.txt", cells("mean sd p50 min max") stats(none) append
	esttab cces_75mi2015 using "$main/tables/tablea3.txt", cells("mean sd p50 min max") stats(none) append
	esttab cces_100mi2014 using "$main/tables/tablea3.txt", cells("mean sd p50 min max") stats(none) append
	esttab cces_100mi2015 using "$main/tables/tablea3.txt", cells("mean sd p50 min max") stats(none) append

*****************************************************************************************
* CODE FOR FIGURE A2: STATISTICS ON NUMBER OF INDIVIDUALS PER CONTEXTUAL UNIT IN THE CCES
*****************************************************************************************
	
	*county-level
	use "$main/data/confed.dta", clear
	duplicates drop countycode, force
    merge 1:m countycode using "$main/data/CCES_full.dta", force
	keep if _m==3
		
	keep if year == 2014 | year == 2015	
	egen tag1 = tag(id countycode)
	*tag unique ids by countycode for each year
	
    egen distinct1 = total(tag1) if year==2014, by(countycode) 
	egen distinct2 = total(tag1) if year==2015, by(countycode) 

	gen distinct1white = distinct1 if race == 1
	gen distinct1black = distinct1 if race == 2
	gen distinct2white = distinct2 if race == 1
	gen distinct2black = distinct2 if race == 2

	collapse distinct1 distinct2 distinct1white distinct1black distinct2white distinct2black, by(countycode year)
	
	*histogram version
	
	#delimit;
	histogram distinct1, frequency color(gray) barwidth(16.2)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(100)900, nogrid labsize(vsmall)) 
	ylab(0(100)600, nogrid labsize(vsmall)) title("CCES 2014", size(small) color(black)) 
	xtitle("Number of Individuals per County", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(A); 
	#delimit cr
	
	#delimit;
	histogram distinct1white, frequency color(gray) barwidth(16.2)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(100)900, nogrid labsize(vsmall)) 
	ylab(0(100)600, nogrid labsize(vsmall)) title("CCES 2014, Whites", size(small) color(black)) 
	xtitle("Number of Individuals per County", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(B); 
	#delimit cr
	
	#delimit;
	histogram distinct1black, frequency color(gray) barwidth(16.2)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(100)900, nogrid labsize(vsmall)) 
	ylab(0(100)600, nogrid labsize(vsmall)) title("CCES 2014, Blacks", size(small) color(black)) 
	xtitle("Number of Individuals per County", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(C); 
	#delimit cr
	
	#delimit;
	histogram distinct2, frequency color(gray) barwidth(4.2)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(50)250, nogrid labsize(vsmall)) 
	ylab(0(100)400, nogrid labsize(vsmall)) title("CCES 2015", size(small) color(black)) 
	xtitle("Number of Individuals per County", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(D); 
	#delimit cr
	
	#delimit;
	histogram distinct2white, frequency color(gray) barwidth(4.2)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(50)250, nogrid labsize(vsmall)) 
	ylab(0(100)400, nogrid labsize(vsmall)) title("CCES 2015, Whites", size(small) color(black)) 
	xtitle("Number of Individuals per County", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(E); 
	#delimit cr
	
	#delimit;
	histogram distinct2black, frequency color(gray) barwidth(4.2)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(50)250, nogrid labsize(vsmall)) 
	ylab(0(100)400, nogrid labsize(vsmall)) title("CCES 2015, Blacks", size(small) color(black)) 
	xtitle("Number of Individuals per County", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(F); 
	#delimit cr
	
	*zipcode-level
	use "$main/data/confed.dta", clear
	duplicates drop zipcode, force
	ren zipcode zip
    merge 1:m zip using "$main/data/CCES_full.dta", force
	keep if _m==3
	ren zip zipcode
		
	keep if year == 2014 | year == 2015
	egen tag1 = tag(id zipcode)
	*tag unique ids by countycode for each year
	
    egen distinct1 = total(tag1) if year==2014, by(zipcode) 
	egen distinct2 = total(tag1) if year==2015, by(zipcode) 
	
	gen distinct1white = distinct1 if race == 1
	gen distinct1black = distinct1 if race == 2
	gen distinct2white = distinct2 if race == 1
	gen distinct2black = distinct2 if race == 2

	collapse distinct1 distinct2 distinct1white distinct1black distinct2white distinct2black, by(zipcode year)

	#delimit;
	histogram distinct1, frequency color(gray) barwidth(0.4)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(5)30, nogrid labsize(vsmall)) 
	ylab(0(50)300, nogrid labsize(vsmall)) title("CCES 2014", size(small) color(black)) 
	xtitle("Number of Individuals per Zipcode", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(G); 
	#delimit cr
	
	#delimit;
	histogram distinct1white, frequency color(gray) barwidth(0.4)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(5)30, nogrid labsize(vsmall)) 
	ylab(0(50)300, nogrid labsize(vsmall)) title("CCES 2014, Whites", size(small) color(black)) 
	xtitle("Number of Individuals per Zipcode", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(H); 
	#delimit cr
	
	#delimit;
	histogram distinct1black, frequency color(gray) barwidth(0.4)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(5)30, nogrid labsize(vsmall)) 
	ylab(0(50)300, nogrid labsize(vsmall)) title("CCES 2014, Blacks", size(small) color(black)) 
	xtitle("Number of Individuals per Zipcode", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(I); 
	#delimit cr
	
	#delimit;
	histogram distinct2, frequency color(gray) barwidth(0.2)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(2)10, nogrid labsize(vsmall)) 
	ylab(0(50)300, nogrid labsize(vsmall)) title("CCES 2015", size(small) color(black)) 
	xtitle("Number of Individuals per Zipcode", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(J); 
	#delimit cr
	
	#delimit;
	histogram distinct2white, frequency color(gray) barwidth(0.2)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(2)10, nogrid labsize(vsmall)) 
	ylab(0(50)300, nogrid labsize(vsmall)) title("CCES 2015, Whites", size(small) color(black)) 
	xtitle("Number of Individuals per Zipcode", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(K); 
	#delimit cr
	
	#delimit;
	histogram distinct2black, frequency color(gray) barwidth(0.2)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(2)10, nogrid labsize(vsmall)) 
	ylab(0(50)300, nogrid labsize(vsmall)) title("CCES 2015, Blacks", size(small) color(black)) 
	xtitle("Number of Individuals per Zipcode", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(L); 
	#delimit cr
		
	graph combine A B C D E F G H I J K L, row(4) graphregion(color(white))
	graph export "$main/figures/figure-2a-appendix.pdf", replace

	graph drop A B C D E F G H I J K L
	
*****************************************************************************************
* CODE FOR FIGURE A3: STATISTICS ON NUMBER OF INDIVIDUALS PER CONTEXTUAL UNIT IN THE VSG
*****************************************************************************************
	
	*county-level
	use "$main/data/confed.dta", clear
	duplicates drop countycode, force
	merge 1:m countycode using "$main/data/VSG_full.dta", force
	keep if _m==3
		
	keep if year == 2016 | year==2017		
	egen tag1 = tag(id countycode) if year==2016
	egen tag2 = tag(id countycode) if year==2017
	*tag unique ids by countycode for each year
	
    egen distinct1 = total(tag1) if tag1==1, by(countycode) 
	egen distinct2 = total(tag2) if tag2==1, by(countycode) 

	gen distinct1white = distinct1 if race == 1
	gen distinct1black = distinct1 if race == 2
	gen distinct2white = distinct2 if race == 1
	gen distinct2black = distinct2 if race == 2

	collapse distinct1 distinct2 distinct1white distinct1black distinct2white distinct2black, by(countycode year)
	*histogram version
	
	#delimit;
	histogram distinct1, frequency color(gray) barwidth(2.2)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(10)100, nogrid labsize(vsmall)) 
	ylab(0(100)400, nogrid labsize(vsmall)) title("VSG 2016", size(small) color(black)) 
	xtitle("Number of Individuals per County", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(A); 
	#delimit cr
	
	#delimit;
	histogram distinct1white, frequency color(gray) barwidth(2.2)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(10)100, nogrid labsize(vsmall)) 
	ylab(0(100)400, nogrid labsize(vsmall)) title("VSG 2016, Whites", size(small) color(black)) 
	xtitle("Number of Individuals per County", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(B); 
	#delimit cr
	
	#delimit;
	histogram distinct1black, frequency color(gray) barwidth(2.2)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(10)100, nogrid labsize(vsmall)) 
	ylab(0(100)400, nogrid labsize(vsmall)) title("VSG 2016, Blacks", size(small) color(black)) 
	xtitle("Number of Individuals per County", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(C); 
	#delimit cr
	
	#delimit;
	histogram distinct2, frequency color(gray) barwidth(2.2)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(10)100, nogrid labsize(vsmall)) 
	ylab(0(100)400, nogrid labsize(vsmall)) title("VSG 2017", size(small) color(black)) 
	xtitle("Number of Individuals per County", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(D); 
	#delimit cr
	
	#delimit;
	histogram distinct2white, frequency color(gray) barwidth(2.2)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(10)100, nogrid labsize(vsmall)) 
	ylab(0(100)400, nogrid labsize(vsmall)) title("VSG 2017, Whites", size(small) color(black)) 
	xtitle("Number of Individuals per County", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(E); 
	#delimit cr
	
	#delimit;
	histogram distinct2black, frequency color(gray) barwidth(2.2)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(10)100, nogrid labsize(vsmall)) 
	ylab(0(100)400, nogrid labsize(vsmall)) title("VSG 2017, Blacks", size(small) color(black)) 
	xtitle("Number of Individuals per County", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(F); 
	#delimit cr

	*zipcode-level
	use "$main/data/confed.dta", clear
	duplicates drop zipcode, force
	ren zipcode zip
	merge 1:m zip using "$main/data/VSG_full.dta", force
	keep if _m==3
	ren zip zipcode
	
	keep if year == 2016 | year == 2017
	
	egen tag1 = tag(id zipcode) if year==2016
	egen tag2 = tag(id zipcode) if year==2017
	*tag unique ids by countycode for each year
	
    egen distinct1 = total(tag1) if tag1==1, by(zipcode) 
	egen distinct2 = total(tag2) if tag2==1, by(zipcode) 

	gen distinct1white = distinct1 if race == 1
	gen distinct1black = distinct1 if race == 2
	gen distinct2white = distinct2 if race == 1
	gen distinct2black = distinct2 if race == 2

	collapse distinct1 distinct2 distinct1white distinct1black distinct2white distinct2black, by(zipcode year)

	#delimit;
	histogram distinct1, frequency color(gray) barwidth(0.1)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(1)6, nogrid labsize(vsmall)) 
	ylab(0(50)250, nogrid labsize(vsmall)) title("VSG 2016", size(small) color(black)) 
	xtitle("Number of Individuals per Zipcode", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(G); 
	#delimit cr
	
	#delimit;
	histogram distinct1white, frequency color(gray) barwidth(0.1)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(1)6, nogrid labsize(vsmall)) 
	ylab(0(50)250, nogrid labsize(vsmall)) title("VSG 2016, Whites", size(small) color(black)) 
	xtitle("Number of Individuals per Zipcode", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(H); 
	#delimit cr
	
	#delimit;
	histogram distinct1black, frequency color(gray) barwidth(0.1)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(1)6, nogrid labsize(vsmall)) 
	ylab(0(50)250, nogrid labsize(vsmall)) title("VSG 2015, Blacks", size(small) color(black)) 
	xtitle("Number of Individuals per Zipcode", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(I); 
	#delimit cr
	
	#delimit;
	histogram distinct2, frequency color(gray) barwidth(0.1)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(1)6, nogrid labsize(vsmall)) 
	ylab(0(50)250, nogrid labsize(vsmall)) title("VSG 2017", size(small) color(black)) 
	xtitle("Number of Individuals per Zipcode", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(J); 
	#delimit cr
	
	#delimit;
	histogram distinct2white, frequency color(gray) barwidth(0.1)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(2)6, nogrid labsize(vsmall)) 
	ylab(0(50)250, nogrid labsize(vsmall)) title("VSG 2017, Whites", size(small) color(black)) 
	xtitle("Number of Individuals per Zipcode", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(K); 
	#delimit cr
	
	#delimit;
	histogram distinct2black, frequency color(gray) barwidth(0.1)
	plotregion(fcolor(white)) graphregion(fcolor(white)) xlab(0(1)6, nogrid labsize(vsmall)) 
	ylab(0(50)250, nogrid labsize(vsmall)) title("VSG 2017, Blacks", size(small) color(black)) 
	xtitle("Number of Individuals per Zipcode", size(small) color(black) margin(small))
	ytitle("Frequency", size(small) color(black) margin(small)) name(L); 
	#delimit cr
		
	graph combine A B C D E F G H I J K L, row(4) graphregion(color(white))
	graph export "$main/figures/figure-3a-appendix.pdf", replace
	
	graph drop A B C D E F G H I J K L

**********************************************************************************************
* CODE FOR TABLE A4: DIFFERENCE IN MEANS TEST FOR CONTEXTUAL UNITS WITH NO SURVEY RESPONDENTS
**********************************************************************************************
	*some of the numbers get rounded with the asdoc output so it is not exactly identical
	*this table was formatted manually in the paper and the details about the std.dev were added manually since could not get asdoc to export this.
		*the std.dev is provided in the commented raw output
	
	ssc install asdoc
	
	*CCES: Counties
	
	use "$main/data/confed.dta", clear
	duplicates drop countycode, force
    merge 1:m countycode using "$main/data/CCES_full.dta", force
	keep if _m==1 | _m==3	
	
	gen missing_county = 1 if _m==1
	replace missing_county = 0 if _m==3
	drop _m
	merge m:1 countycode using "$main/data/2010Census_county_population.dta"
	keep if _m==3
	drop _m
	
	collapse Black_Pop DemVote12 CENSUS2010POP missing_county, by(countycode)
	
	asdoc ttest CENSUS2010POP, by(missing_county), replace title(T-test results : H1: mean = 0) save(tableA4.doc) 
	
	/*Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     736    156833.1    18298.79    496433.6      120909    192757.2
       1 |      10      3311.9     920.782    2911.768    1228.946    5394.854
---------+--------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =   0.9773
Ho: diff = 0                                     degrees of freedom =      744

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.8356         Pr(|T| > |t|) = 0.3287          Pr(T > t) = 0.1644
*/
	
	asdoc ttest Black_Pop, by(missing_county), rowappend 

/*
	*Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     592    .3060304    .0092384    .2247788    .2878864    .3241744
       1 |       5        .406    .1453823    .3250846    .0023542    .8096458
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =  -0.9867
Ho: diff = 0                                     degrees of freedom =      595

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.1621         Pr(|T| > |t|) = 0.3242          Pr(T > t) = 0.8379
*/

	asdoc ttest DemVote12, by(missing_county), rowappend

/*

------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     696    .4302011    .0063311    .1670246    .4177709    .4426314
       1 |       9    .3477778    .0880148    .2640444    .1448153    .5507403
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =   1.4586
Ho: diff = 0                                     degrees of freedom =      703

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.9274         Pr(|T| > |t|) = 0.1451          Pr(T > t) = 0.0726


*/

	*CCES: Zipcodes
	
	use "$main/data/confed.dta", clear
	duplicates drop zipcode, force
	ren zipcode zip
    merge 1:m zip using "$main/data/CCES_full.dta", force
	keep if _m==1 | _m==3		
	gen missing_zip = 1 if _m==1
	replace missing_zip = 0 if _m==3
	drop _m
	drop percent_black percent_white med_hh_income pop2010
	merge m:1 zip using "$main/data/zipcode_cov.dta"
	keep if _m==3
	drop _m
	merge m:1 zip using  "$main/data/2010Census_zip_population.dta"
	keep if _m==3
	ta missing_zip

	collapse percent_black percent_white percent_college med_hh_income pop2010 missing_zip, by(zip)
	
	asdoc ttest pop2010, by(missing_zip), rowappend
	
	/*
	
Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     736    156833.1    18298.79    496433.6      120909    192757.2
       1 |      10      3311.9     920.782    2911.768    1228.946    5394.854
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =   0.9773
Ho: diff = 0                                     degrees of freedom =      744

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.8356         Pr(|T| > |t|) = 0.3287          Pr(T > t) = 0.1644	
	*/
		
	asdoc ttest percent_black, by(missing_zip), rowappend

/*
Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |   1,029    .2268896    .0064487    .2068619    .2142355    .2395437
       1 |      67    .1692028     .027622    .2260957    .1140537    .2243519
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =   2.1989
Ho: diff = 0                                     degrees of freedom =     1094

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.9860         Pr(|T| > |t|) = 0.0281          Pr(T > t) = 0.0140
*/
	
	asdoc ttest percent_white, by(missing_zip), rowappend
/*

Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |   1,029    .7010165    .0064508    .2069305    .6883582    .7136749
       1 |      66     .697449    .0379353    .3081877     .621687     .773211
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =   0.1311
Ho: diff = 0                                     degrees of freedom =     1093

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.5521         Pr(|T| > |t|) = 0.8957          Pr(T > t) = 0.4479
*/

	asdoc ttest med_hh_income, by(missing_zip), rowappend

/*

Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |   1,029    48009.08    565.4624    18138.92    46899.49    49118.68
       1 |      66    39892.29    2324.432    18883.77    35250.08     44534.5
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =   3.5153
Ho: diff = 0                                     degrees of freedom =     1093

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.9998         Pr(|T| > |t|) = 0.0005          Pr(T > t) = 0.0002


*/
	

	*VSG: Counties
	
	use "$main/data/confed.dta", clear
	duplicates drop countycode, force
	merge 1:m countycode using "$main/data/VSG_full.dta", force
	keep if _m==1 | _m==3
	gen missing_county = 1 if _m==1
	replace missing_county = 0 if _m==3
	drop _m
	merge m:1 countycode using "$main/data/2010Census_county_population.dta"
	keep if _m==3
	drop _m
	
	collapse Black_Pop DemVote12 CENSUS2010POP missing_county, by(countycode)
	asdoc ttest CENSUS2010POP, by(missing_county), rowappend
	
/*

Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     424    249973.2    30992.01    638164.6    189055.7    310890.7
       1 |     322    29421.22    1390.546    24952.45    26685.49    32156.95
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =   6.1970
Ho: diff = 0                                     degrees of freedom =      744

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

*/
	
	asdoc ttest Black_Pop, by(missing_county), rowappend
	
/*

Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     351    .2727066    .0111213    .2083577    .2508335    .2945796
       1 |     246    .3556098    .0153193    .2402742    .3254354    .3857841
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =  -4.4900
Ho: diff = 0                                     degrees of freedom =      595

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 1.0000

*/
	
	asdoc ttest DemVote12, by(missing_county), rowappend

/*

Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     402    .4369154    .0082216    .1648424    .4207526    .4530782
       1 |     303    .4188449     .009947    .1731467    .3992706    .4384191
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =   1.4100
Ho: diff = 0                                     degrees of freedom =      703

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.9205         Pr(|T| > |t|) = 0.1590          Pr(T > t) = 0.0795
*/	
	
	*VSG: Zipcodes
	
	use "$main/data/confed.dta", clear
	duplicates drop zipcode, force
	ren zipcode zip
	merge 1:m zip using "$main/data/VSG_full.dta", force
	keep if _m==1 | _m==3
	gen missing_zip = 1 if _m==1
	replace missing_zip = 0 if _m==3
	drop _m
	drop percent_black percent_white med_hh_income pop2010
	merge m:1 zip using "$main/data/zipcode_cov.dta"
	keep if _m==3
	drop _m
	merge m:1 zip using  "$main/data/2010Census_zip_population.dta"
	keep if _m==3
	ta missing_zip
	
	collapse percent_black percent_white percent_college med_hh_income pop2010 missing_zip, by(zip)
	asdoc ttest pop2010, by(missing_zip), rowappend

/*
Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     351    27698.75    737.1649    13810.78    26248.92    29148.58
       1 |     746    14707.65    446.7532    12202.17    13830.61     15584.7
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =  15.7561
Ho: diff = 0                                     degrees of freedom =     1095

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000

*/
	
	asdoc ttest percent_black, by(missing_zip), rowappend

/*
Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     351    .2303533    .0108039     .202411    .2091046     .251602
       1 |     745    .2200698    .0077403    .2112699    .2048743    .2352652
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =   0.7619
Ho: diff = 0                                     degrees of freedom =     1094

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.7769         Pr(|T| > |t|) = 0.4463          Pr(T > t) = 0.2231

*/
	
	asdoc ttest percent_white, by(missing_zip), rowappend

/*
Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     351    .6933413    .0109471     .205093     .671811    .7148716
       1 |     744     .704321    .0080072    .2184086    .6886015    .7200405
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =  -0.7915
Ho: diff = 0                                     degrees of freedom =     1093

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.2144         Pr(|T| > |t|) = 0.4288          Pr(T > t) = 0.7856
*/

	asdoc ttest med_hh_income, by(missing_zip), rowappend
	
/*
Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     351    51794.68    1041.211    19507.09    49746.86     53842.5
       1 |     744     45503.1    634.9627    17319.47    44256.56    46749.63
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =   5.3832
Ho: diff = 0                                     degrees of freedom =     1093

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 1.0000         Pr(|T| > |t|) = 0.0000          Pr(T > t) = 0.0000
*/

**********************************************************************************************
* CODE FOR TABLE A5: DIFFERENCE IN MEANS TEST FOR CONTEXTUAL UNITS WITH AND WITHOUT REMOVALS
**********************************************************************************************
	*similarly does not replicate exactly the same with this asdoc because of rounding nad needed to add in std. dev manually
	*CCES: Counties
	
	use "$main/data/CCES_full_county.dta", clear
	keep if year == 2014 | year == 2015
	
	*gen removed dummy tag counties with removals
	bysort countycode: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	by countycode: egen treated = max(removed)
	drop if monthly_date_confed<=tm(2014m2)
	
	merge m:1 countycode using "$main/data/2010Census_county_population.dta"
	keep if _m==3
	drop _m

	collapse Black_Pop DemVote12 CENSUS2010POP treated, by(countycode)
	
	asdoc ttest CENSUS2010POP, by(treated), replace title(T-test results : H1: mean = 0) save(tableA5.doc)
	
	/*
	
Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     664    163365.1    20073.62    517261.1    123949.5    202780.6
       1 |      14    434913.4    89542.32    335036.7      241469    628357.8
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =  -1.9548
Ho: diff = 0                                     degrees of freedom =      676

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.0255         Pr(|T| > |t|) = 0.0510          Pr(T > t) = 0.9745

	*/
	
	asdoc ttest Black_Pop, by(treated), rowappend

/*
Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     546    .3022224    .0094771    .2214484    .2836062    .3208385
       1 |      13    .2692308    .0527386    .1901518    .1543232    .3841383
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =   0.5324
Ho: diff = 0                                     degrees of freedom =      557

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.7027         Pr(|T| > |t|) = 0.5947          Pr(T > t) = 0.2973

*/
	
	asdoc ttest DemVote12, by(treated), rowappend

/*

Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     636    .4288884    .0065145    .1642893    .4160958    .4416809
       1 |      14    .5185714    .0452205    .1691998    .4208784    .6162645
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =  -2.0192
Ho: diff = 0                                     degrees of freedom =      648

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.0219         Pr(|T| > |t|) = 0.0439          Pr(T > t) = 0.9781

*/

	*CCES: Zipcodes
	
	use "$main/data/CCES_full_zip.dta", clear
	keep if year == 2014 | year == 2015

	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	
	collapse percent_black percent_white percent_college med_hh_income pop2010 treated, by(zip)
	
	asdoc ttest pop2010, by(treated), rowappend

/*
Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     835     22433.2    466.7726    13488.03    21517.01    23349.39
       1 |      11    23540.82    3096.797    10270.92    16640.72    30440.91
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =  -0.2713
Ho: diff = 0                                     degrees of freedom =      844

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.3931         Pr(|T| > |t|) = 0.7863          Pr(T > t) = 0.6069
*/
	
	asdoc ttest percent_black, by(treated), rowappend

/*
Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     835    .2303925    .0070825    .2046595    .2164908    .2442942
       1 |      11    .1408079    .0397468    .1318252    .0522465    .2293693
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =   1.4473
Ho: diff = 0                                     degrees of freedom =      844

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.9259         Pr(|T| > |t|) = 0.1482          Pr(T > t) = 0.0741
*/
	
	asdoc ttest percent_white, by(treated), rowappend

/*
Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     835    .6964447    .0070519    .2037737    .6826032    .7102862
       1 |      11    .7823785    .0368501    .1222179    .7002713    .8644856
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =  -1.3948
Ho: diff = 0                                     degrees of freedom =      844

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.0817         Pr(|T| > |t|) = 0.1634          Pr(T > t) = 0.9183
*/
	
	asdoc ttest med_hh_income, by(treated), rowappend
	
/*
Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     835    48833.99    632.9954    18291.27    47591.54    50076.44
       1 |      11    57111.91    9188.489    30474.77    36638.68    77585.14
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =  -1.4757
Ho: diff = 0                                     degrees of freedom =      844

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.0702         Pr(|T| > |t|) = 0.1404          Pr(T > t) = 0.9298
*/

	*VSG: Counties
	
	*slightly different counties without removals across 3, lower bound 323 upper bound 393
	use "$main/data/VSG_full_county.dta", clear
	keep if year == 2016 | year == 2017
	
	bysort countycode: gen byte removed = inrange(monthly_date_confed, tm(2017m1), tm(2017m7))
	by countycode: egen treated = max(removed)

	merge m:1 countycode using "$main/data/2010Census_county_population.dta"
	keep if _m==3
	drop _m
	
	collapse Black_Pop DemVote12 CENSUS2010POP treated, by(countycode)
	
	asdoc ttest CENSUS2010POP, by(treated), rowappend

/*
Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     393    245672.4    31682.96    628090.2    183382.6    307962.2
       1 |       7     1147813    513064.5     1357441   -107610.3     2403237
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =  -3.6667
Ho: diff = 0                                     degrees of freedom =      398

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.0001         Pr(|T| > |t|) = 0.0003          Pr(T > t) = 0.9999

*/
	
	asdoc ttest Black_Pop, by(treated), rowappend

/*

Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     326    .2687528    .0113117    .2042387    .2464994    .2910063
       1 |       7    .3057143     .077209    .2042757    .1167908    .4946378
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =  -0.4737
Ho: diff = 0                                     degrees of freedom =      331

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.3180         Pr(|T| > |t|) = 0.6360          Pr(T > t) = 0.6820

*/

	asdoc ttest DemVote12, by(treated), rowappend

/*
Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     380    .4336132    .0084093    .1639268    .4170785    .4501478
       1 |       7    .6185714    .0616607    .1631389    .4676932    .7694497
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =  -2.9583
Ho: diff = 0                                     degrees of freedom =      385

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.0016         Pr(|T| > |t|) = 0.0033          Pr(T > t) = 0.9984
*/

	*VSG: Zipcodes
	
	use "$main/data/VSG_full_zip.dta", clear
	keep if year == 2016 | year == 2017

	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2017m1), tm(2017m7))
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2016m12) 

	collapse percent_black percent_white percent_college med_hh_income pop2010 treated, by(zip)
	
	asdoc ttest pop2010, by(treated), rowappend

/*

Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     290    28313.08    785.9631    13384.47    26766.14    29860.02
       1 |       4     24570.5     5854.52    11709.04    5938.805    43202.19
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =   0.5561
Ho: diff = 0                                     degrees of freedom =      292

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.7107         Pr(|T| > |t|) = 0.5786          Pr(T > t) = 0.2893

*/

	asdoc ttest percent_black, by(treated), rowappend

/*
Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     290    .2342075    .0122978    .2094244    .2100028    .2584121
       1 |       4    .3030352    .1431962    .2863925   -.1526791    .7587496
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =  -0.6499
Ho: diff = 0                                     degrees of freedom =      292

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.2581         Pr(|T| > |t|) = 0.5163          Pr(T > t) = 0.7419
*/
 
	asdoc ttest percent_white, by(treated), rowappend

/*
Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     290    .6940362    .0123366    .2100855    .6697552    .7183173
       1 |       4     .614043    .1541934    .3083869    .1233307    1.104755
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =   0.7519
Ho: diff = 0                                     degrees of freedom =      292

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.7736         Pr(|T| > |t|) = 0.4527          Pr(T > t) = 0.2264
*/
	
	asdoc ttest med_hh_income, by(treated), rowappend
	
/*

Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. Err.   Std. Dev.   [95% Conf. Interval]
---------+--------------------------------------------------------------------
       0 |     290    52177.61    1165.062    19840.29    49884.53     54470.7
       1 |       4    48705.25    7622.653    15245.31    24446.57    72963.93
------------------------------------------------------------------------------
    diff = mean(0) - mean(1)                                      t =   0.3484
Ho: diff = 0                                     degrees of freedom =      292

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.6361         Pr(|T| > |t|) = 0.7278          Pr(T > t) = 0.3639
*/

**********************************************************************************************
* CODE FOR TABLE A6: EFFECT OF PUBLIC DEBATES (ACTIVE SYMBOLS) FOR NOV 2014 VS DEC 2015 (CCES)
**********************************************************************************************

	use "$main/data/CCES_full_county_updated-withdebates.dta", clear

* county-level
		
	*only include counties that had at least one symbol at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015	
	keep if symbolstatus=="active"
		
	egen tag = tag(countycode Unique_ID) 
	egen totalmon = total(tag), by(countycode)
	
	ta totalmon if monthly_date_confed<tm(2015m7)
	*none with zero monuments at the start of June 2015 so don't drop any counties from sammple

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: at least one symbol debated but not removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
	
	gen debated_not_removed=1 if symbolstatus=="active" & some_debate==1
	replace debated_not_removed=0 if debated_not_removed==.
			
	bysort countycode: egen treated = max(debated_not_removed)
	
	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm religion_important Black_Pop logpop DemVote12, by(state year region countycode pre_post treated did)

	xtset countycode year  
	by countycode, sort: egen obs = count(year)
	drop if obs <2
	drop obs
	
	*need to interact covariates with post-treatment indicator
	gen black_post = Black_Pop*pre_post
	gen Dem_post = DemVote12*pre_post
	gen pop_post = logpop*pre_post

	sum symbolic_index if year==2014, detail
	*0.68 mean, median of 0.68 [reported mean value of dependent variable in Table A6]
	sum affirm if year==2014, detail
	*0.34 mean, median of 0.33 [reported mean value of dependent variable in Table A6]

	*generate the interaction term 
	gen treated_prepost = treated*pre_post

	* REGRESSIONS :  
				
	quietly eststo countyRR1: reghdfe symbolic_index treated pre_post treated_prepost black_post pop_post Dem_post, vce(cluster countycode) absorb(i.countycode i.year)	
	quietly eststo countyRR2: reghdfe symbolic_index treated pre_post treated_prepost black_post pop_post Dem_post i.state##c.year, vce(cluster countycode) absorb(i.countycode)
	quietly eststo countyAA1: reghdfe affirm treated pre_post treated_prepost black_post pop_post Dem_post, vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countyAA2: reghdfe affirm treated pre_post treated_prepost black_post pop_post Dem_post i.state##c.year, vce(cluster countycode) absorb(i.countycode)

	esttab countyRR1 countyRR2 countyAA1 countyAA2 using "$main/tables/tableA6-county.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

*Zipcode-level*
		
	use "$main/data/CCES_full_zip_updated-withdebates.dta", clear
	
	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
	keep if symbolstatus=="active"
		
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0
	
	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: at least one symbol debated but not removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015

	gen debated_not_removed=1 if symbolstatus=="active" & some_debate==1
	replace debated_not_removed=0 if debated_not_removed==.
	
	bysort countycode: egen treated = max(debated_not_removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm religion_important percent_black percent_college med_hh_income percent_white logpop, by(zip state year region countycode pre_post treated did)
	
	xtset zip year 
	by zip, sort: egen obs = count(year)
	drop if obs <2
	drop obs

	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post

	sum symbolic_index if year==2014, detail
	*0.62 mean, median of 0.63 [reported mean value of dependent variable in Table A6]
	sum affirm if year==2014, detail
	*0.42 mean, median of 0.4 [reported mean value of dependent variable in Table A6]
	
	*generate the interaction term 
	gen treated_prepost = treated*pre_post

	* REGRESSIONS :  

	quietly eststo zipRR1: reghdfe symbolic_index treated pre_post treated_prepost black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipRR2: reghdfe symbolic_index treated pre_post treated_prepost black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)
	quietly eststo zipAA1: reghdfe affirm treated pre_post treated_prepost black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipAA2: reghdfe affirm treated pre_post treated_prepost black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)

	esttab zipRR1 zipRR2 zipAA1 zipAA2 using "$main/tables/tablea6-zip.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

***********************************************************************************************
* CODE FOR TABLE A7: EFFECT of PUBLIC DEBATES (ACTIVE SYMBOLS) for DEC 2016 vs JULY 2017, (VSG)
***********************************************************************************************

*county-level 
	
	use "$main/data/VSG_debates_county.dta", clear
	keep if year == 2016 | year == 2017

	egen tag = tag(countycode Unique_ID) 
	egen totalmon = total(tag), by(countycode)

	ta totalmon if monthly_date_confed<tm(2016m12)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_vsg == tm(2017m7) if !missing(monthly_date_vsg)

	*treatment period group: at least one symbol debated but not removed after December 2016 for 2016 VSG and before July 2017 for 2017 VSG
	*control group: monuments still active after July 2017

	gen debated_not_removed=1 if symbolstatus=="active" & some_debate==1
	replace debated_not_removed=0 if debated_not_removed==.
				
	bysort countycode: egen treated = max(debated_not_removed)

	drop if monthly_date_confed<=tm(2016m12)

	*also collapsing 
	gen did = pre_post*treated 

	*create a line by zipcode year treatment status
	collapse ft_blacks age race liberal conserv educ male, by(id state countycode year pre_post treated did)

	gen age2 = age*age

	* without any controls yet
	xtset id year

	sum ft_blacks if year==2016, detail
	*mean 0.72, median 0.77 [reported mean value of dependent variable in Table A7]

	*generate the interaction term 
	gen treated_prepost = treated*pre_post

	* REGRESSIONS :  

	quietly eststo countyFT1: reghdfe ft_blacks  treated pre_post treated_prepost age age2 race liberal educ male liberal conserv, vce(cluster countycode) absorb(i.id i.year)
	quietly eststo countyFT2: reghdfe ft_blacks  treated pre_post treated_prepost age age2 race liberal educ male liberal conserv i.state##c.year, vce(cluster countycode) absorb(i.id)

*zipcode-level

	use "$main/data/VSG_debates_zip.dta", clear
	keep if year == 2016 | year == 2017
	
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)
	
	ta totalmon if monthly_date_confed<tm(2016m12)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_vsg == tm(2017m7) if !missing(monthly_date_vsg)
	
	*treatment period group: at least one symbol debated but not removed after December 2016 for 2016 VSG and before July 2017 for 2017 VSG
	*control group: monuments still active after July 2017
	
	gen debated_not_removed=1 if symbolstatus=="active" & some_debate==1
	replace debated_not_removed=0 if debated_not_removed==.
				
	bysort zip: egen treated = max(debated_not_removed)

	drop if monthly_date_confed<=tm(2016m12) 
	*also collapsing 
	gen did = pre_post*treated 
	
	*create a line by zipcode year treatment status
	collapse ft_blacks age race liberal conserv educ male, by(id zip state countycode year pre_post treated did)

	gen age2 = age*age

	xtset id year  
	
	sum ft_blacks if year==2016, detail
	*mean 0.73, median 0.78 [reported mean value of dependent variable in Table A7]
	
	*generate the interaction term 
	gen treated_prepost = treated*pre_post
	
	* REGRESSIONS :  

	quietly eststo zipFT1: reghdfe ft_blacks  treated pre_post treated_prepost age age2 race liberal conserv educ male, vce(cluster zip) absorb(i.id i.year)
	quietly eststo zipFT2: reghdfe ft_blacks  treated pre_post treated_prepost age age2 race liberal conserv educ male i.state##c.year, vce(cluster zip) absorb(i.id i.year)	

	esttab countyFT1 countyFT2 zipFT1 zipFT2 using "$main/tables/tablea7.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace
	
***************************************************************************************************
* CODE FOR TABLE A8: EFFECT of EVENTUAL REMOVALS for SYMBOLS THAT WERE NEITHER REMOVED NOR DEBATED 
***************************************************************************************************

*Zipcode-level

	* subset sample to places with no symbols removed between 2014-2015 (the control group)
	
	use "$main/data/CCES_full_zip_updated-withdebates.dta", clear
	
	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
		
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0
	
	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
			
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	keep if treated ==0
	
	*this is now the sample of zipcodes that had no removals between 2014-2015
	
	*the pseudo-treated variable is going to be places that did remove eventually after Dec 2015 (and had no debates between 2014-2015)
	keep if some_debate==0
	
	drop removed treated
	bysort zip: gen byte removed = monthly_date_confed>tm(2015m12)
	replace removed = 0 if monthly_date_confed==.
	
	by zip: egen pseudotreated = max(removed)

	gen did = pre_post*pseudotreated 
	
	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm religion_important percent_black percent_college med_hh_income percent_white logpop, by(zip state year region countycode pre_post pseudotreated did)

	xtset zip year 
	by zip, sort: egen obs = count(year)
	drop if obs <2
	drop obs

	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post

	sum symbolic_index if year==2014, detail
	*0.61 mean, median of 0.63 [reported mean value of dependent variable in Table A8]
	sum affirm if year==2014, detail
	*0.43 mean, median of 0.43 [reported mean value of dependent variable in Table A8]

	*generate the interaction term 
	gen treated_prepost = pseudotreated*pre_post

	* REGRESSIONS :  
		
	quietly eststo zipRR1a: reghdfe symbolic_index pseudotreated pre_post treated_prepost black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipRR2a: reghdfe symbolic_index pseudotreated pre_post treated_prepost black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)
	quietly eststo zipAA1a: reghdfe affirm pseudotreated pre_post treated_prepost black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)	
	quietly eststo zipAA2a: reghdfe affirm pseudotreated pre_post treated_prepost black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)
	
	esttab zipRR1a zipRR2a zipAA1a zipAA2a using "$main/tables/tablea8.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

***********************************************************************
* CODE FOR FIGURE A.4: LEAVE ONE OUT TEST FOR FORMER CONFEDERATE STATES
***********************************************************************

	* DROP ALABAMA 	 *

	use "$main/data/CCES_full_zip.dta", clear	
	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
	keep if Conf_State==1
	
	decode state, gen(state_str)

	*drop state by state

	drop if state_str=="Alabama"
	
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
		
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 

	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm percent_black percent_college percent_white logpop med_hh_income, by(zip state year region countycode pre_post treated did)
	
	xtset zip year  

	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post
	
	*Regressions
	quietly eststo AlabamaR: reghdfe symbolic_index i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo AlabamaA: reghdfe affirm i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 

	* DROP ARKANSAS 	 *
	use "$main/data/CCES_full_zip.dta", clear
	
	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
	keep if Conf_State==1
	
	decode state, gen(state_str)

	*drop state by state
	drop if state_str=="Arkansas"
	
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
		
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 

	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm percent_black percent_college percent_white logpop med_hh_income, by(zip state year region countycode pre_post treated did)
	
	xtset zip year  

	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post
	
	*Regressions
	quietly eststo ArkansasR: reghdfe symbolic_index i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo ArkansasA: reghdfe affirm i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 

	* DROP FLORIDA 	 *	
	use "$main/data/CCES_full_zip.dta", clear

	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
	keep if Conf_State==1
	
	decode state, gen(state_str)

	*drop state by state

	drop if state_str=="Florida"
	
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
		
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 

	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm percent_black percent_college percent_white logpop med_hh_income, by(zip state year region countycode pre_post treated did)
	
	xtset zip year  

	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post
	
	*Regressions
	quietly eststo FloridaR: reghdfe symbolic_index i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo FloridaA: reghdfe affirm i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 

	* DROP GEORGIA 	 *	
	use "$main/data/CCES_full_zip.dta", clear

	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
	keep if Conf_State==1
	
	decode state, gen(state_str)

	*drop state by state

	drop if state_str=="Georgia"
	
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
		
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 

	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm percent_black percent_college percent_white logpop med_hh_income, by(zip state year region countycode pre_post treated did)
	
	xtset zip year  

	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post
	
	*Regressions
	quietly eststo GeorgiaR: reghdfe symbolic_index i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 		
	quietly eststo GeorgiaA: reghdfe affirm i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 

	* DROP LOUISIANA 	 *	
	use "$main/data/CCES_full_zip.dta", clear
	
	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
	keep if Conf_State==1
	
	decode state, gen(state_str)

	*drop state by state

	drop if state_str=="Louisiana"
	
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
		
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 

	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm percent_black percent_college percent_white logpop med_hh_income, by(zip state year region countycode pre_post treated did)
	
	xtset zip year  

	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post
	
	*Regressions
	quietly eststo LouisianaR: reghdfe symbolic_index i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 		
	quietly eststo LouisianaA: reghdfe affirm i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 

	* DROP MISSISSIPPI 	 *	
	use "$main/data/CCES_full_zip.dta", clear

	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
	keep if Conf_State==1
	
	decode state, gen(state_str)

	*drop state by state

	drop if state_str=="Mississippi"
	
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
		
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 

	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm percent_black percent_college percent_white logpop med_hh_income, by(zip state year region countycode pre_post treated did)
	
	xtset zip year  

	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post
	
	*Regressions
	quietly eststo MissR: reghdfe symbolic_index i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo MissA: reghdfe affirm i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 

	* DROP NORTH CAROLINA *	
	use "$main/data/CCES_full_zip.dta", clear
	
	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
	keep if Conf_State==1
	
	decode state, gen(state_str)

	*drop state by state

	drop if state_str=="North Carolina"
	
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
		
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 

	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm percent_black percent_college percent_white logpop med_hh_income, by(zip state year region countycode pre_post treated did)
	
	xtset zip year  

	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post
	
	*Regressions:
	quietly eststo NCR: reghdfe symbolic_index i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo NCA: reghdfe affirm i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 

	* DROP SOUTH CAROLINA *
	use "$main/data/CCES_full_zip.dta", clear

	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
	keep if Conf_State==1
	
	decode state, gen(state_str)

	*drop state by state

	drop if state_str=="South Carolina"
	
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
		
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 

	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm percent_black percent_college percent_white logpop med_hh_income, by(zip state year region countycode pre_post treated did)
	
	xtset zip year  

	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post
	
	*Regressions
	quietly eststo SCR: reghdfe symbolic_index i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo SCA: reghdfe affirm i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 

	* DROP TENNESSEE	 *	
	use "$main/data/CCES_full_zip.dta", clear

	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
	keep if Conf_State==1
	
	decode state, gen(state_str)

	*drop state by state

	drop if state_str=="Tennessee"
	
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
		
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 

	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm percent_black percent_college percent_white logpop med_hh_income, by(zip state year region countycode pre_post treated did)
	
	xtset zip year  

	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post
	
	*Regressions
	quietly eststo TennR: reghdfe symbolic_index i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo TennA: reghdfe affirm i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 

	* DROP TEXAS	 *	
	use "$main/data/CCES_full_zip.dta", clear

	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
	keep if Conf_State==1
	
	decode state, gen(state_str)

	*drop state by state

	drop if state_str=="Texas"
	
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
		
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 

	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm percent_black percent_college percent_white logpop med_hh_income, by(zip state year region countycode pre_post treated did)
	
	xtset zip year  

	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post
	
	*Regressions
	quietly eststo TexasR: reghdfe symbolic_index i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo TexasA: reghdfe affirm i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 

	* DROP VIRGINIA	 *	
	use "$main/data/CCES_full_zip.dta", clear

	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
	keep if Conf_State==1
	
	decode state, gen(state_str)

	*drop state by state

	drop if state_str=="Virginia"
	
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
		
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 

	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm percent_black percent_college percent_white logpop med_hh_income, by(zip state year region countycode pre_post treated did)
	
	xtset zip year  

	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post
	
	*Regressions
	quietly eststo VirginiaR: reghdfe symbolic_index i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo VirginiaA: reghdfe affirm i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 

	*Figure A.4 (a little bit of manual formatting done to add labels for each state and x-axis)
	graph drop A

	#delimit;
	coefplot (AlabamaR, mcolor(black) ciopts(lcolor(black) lcol(black)))
	(AlabamaA, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(ArkansasR, mcolor(black) ciopts(lcolor(black)))
	(ArkansasA, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(FloridaR, mcolor(black) ciopts(lcolor(black) lcol(black)))
	(FloridaA, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(GeorgiaR, mcolor(black) ciopts(lcolor(black)))
	(GeorgiaA, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(LouisianaR, mcolor(black) ciopts(lcolor(black) lcol(black)))
	(LouisianaA, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(MissR, mcolor(black) ciopts(lcolor(black) lcol(black)))
	(MissA, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(NCR, mcolor(black) ciopts(lcolor(black) lcol(black)))
	(NCA, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(SCR, mcolor(black) ciopts(lcolor(black) lcol(black)))
	(SCA, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(TennR, mcolor(black) ciopts(lcolor(black) lcol(black)))
	(TennA, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(TexasR, mcolor(black) ciopts(lcolor(black) lcol(black)))
	(TexasA, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(VirginiaR, mcolor(black) ciopts(lcolor(black) lcol(black)))
	(VirginiaA, mcolor(gray) ciopts(lcolor(gray) lcol(gray))), keep(1.treated#1.pre_post) 
	xline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white)) 
	mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "+", "")))))
	xlab(-.9(0.1).9, nogrid) msymbol(d) mfcolor(white) legend(off)
	ylab("") title("Leave One Out Test: Former Confederate States", size(medium) color(black)) name(A);
	#delimit cr
	graph export "$main/figures/figure-a4-appendix.pdf", replace
	
	*note that this graph was edited manually in Stata to add in the state name labels 

	graph drop A

********************************************************************************************
* CODE FOR TABLE A9: EFFECT OF REMOVALS FOR NOV 2014 v DEC 2015, WEIGHTED BY SYMBOLS (CCES) 
*******************************************************************************************

set more off

*county-level 
	set more off
	use "$main/data/CCES_full_county.dta", clear

	*only include counties that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015

	egen tag = tag(countycode Unique_ID) 
	egen totalmon = total(tag), by(countycode)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*by countycode: egen weight = count(Unique_ID)

	unique Unique_ID, by(countycode) gen(weight)
	
	*need to replace all the missings with the same value by countycode to make sure they are counted

	qui bysort countycode (weight): replace weight=weight[1]
	
	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015

	bysort countycode: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	by countycode: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 

	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm Black_Pop logpop DemVote12 weight, by(state year region countycode pre_post treated did)

	xtset countycode year 
	
	*need to interact covariates with post-treatment indicator
	gen black_post = Black_Pop*pre_post
	gen Dem_post = DemVote12*pre_post
	gen pop_post = logpop*pre_post
	
	*generate the interaction term 
	gen treated_prepost = treated*pre_post
	
	*Regressions
	quietly eststo countyRR1: reghdfe symbolic_index treated_prepost black_post pop_post Dem_post [aw=weight], vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countyRR2: reghdfe symbolic_index treated_prepost black_post pop_post Dem_post i.state##c.year [aw=weight], vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countyAA1: reghdfe affirm treated_prepost black_post pop_post Dem_post [aw=weight], vce(cluster countycode) absorb(i.countycode i.year)	
	quietly eststo countyAA2: reghdfe affirm treated_prepost black_post pop_post Dem_post i.state##c.year [aw=weight], vce(cluster countycode) absorb(i.countycode i.year)

	esttab countyRR1 countyRR2 countyAA1 countyAA2 using "$main/tables/tablea9-county.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

*zipcode-level
	set more off 
	
	use "$main/data/CCES_full_zip.dta", clear
	
	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015

	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015

	*generate a weight for number of symbols per zipcode
	unique Unique_ID, by(countycode) gen(weight)
	
	*need to replace all the missings with the same value by countycode to make sure they are counted

	qui bysort countycode (weight): replace weight=weight[1]
			
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
			
	collapse symbolic_index affirm percent_black percent_college percent_white logpop med_hh_income weight, by(zip state year region countycode pre_post treated did)
	
	xtset zip year  
	
	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post

	*generate the interaction term 
	gen treated_prepost = treated*pre_post

	*Regressions
	quietly eststo zipRR1: reghdfe symbolic_index treated_prepost black_post college_post white_post income_post pop_post [aw=weight], vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipRR2: reghdfe symbolic_index treated_prepost black_post college_post white_post income_post pop_post i.state##c.year [aw=weight], vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo zipAA1: reghdfe affirm treated_prepost black_post college_post white_post income_post pop_post [aw=weight], vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo zipAA2: reghdfe affirm treated_prepost black_post college_post white_post income_post pop_post i.state##c.year [aw=weight], vce(cluster zip) absorb(i.zip i.year) 

	esttab zipRR1 zipRR2 zipAA1 zipAA2 using "$main/tables/tablea9-zip.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

************************************************************************************************
* CODE FOR TABLE A10: EFFECT OF REMOVALS FOR NOV 2014 v DEC 2015, WEIGHTED BY RESPONDENTS (CCES) 
************************************************************************************************

*weight zipcodes and counties with more vs. less respondents
	
	set more off

*county-level	
	
	use "$main/data/CCES_full_county.dta", clear
	
	*only include counties that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015

	egen tag = tag(countycode Unique_ID) 
	egen totalmon = total(tag), by(countycode)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0
	
	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015

	bysort countycode: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	by countycode: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 

	gen logpop = log(pop2010) 
	
	collapse weight_county symbolic_index affirm Black_Pop logpop DemVote12, by(state year region countycode pre_post treated did)

	xtset countycode year 
	
	*need to interact covariates with post-treatment indicator
	gen black_post = Black_Pop*pre_post
	gen Dem_post = DemVote12*pre_post
	gen pop_post = logpop*pre_post
	
	*generate the interaction term 
	gen treated_prepost = treated*pre_post

	*Regressions
	quietly eststo countyRR1: reghdfe symbolic_index treated_prepost black_post pop_post Dem_post [aw=weight_county], vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countyRR2: reghdfe symbolic_index treated_prepost black_post pop_post Dem_post i.state##c.year [aw=weight_county], vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countyAA1: reghdfe affirm treated_prepost black_post pop_post Dem_post [aw=weight_county], vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countyAA2: reghdfe affirm treated_prepost black_post pop_post Dem_post i.state##c.year [aw=weight_county], vce(cluster countycode) absorb(i.countycode i.year)
	
	esttab countyRR1 countyRR2 countyAA1 countyAA2 using "$main/tables/tablea10-county.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

*Zipcode-level
	
	set more off
	use "$main/data/CCES_full_zip.dta", clear
	
	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015

	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
		
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
			
	collapse symbolic_index affirm percent_black percent_college percent_white logpop med_hh_income weight_zip, by(zip state year region countycode pre_post treated did)
	
	xtset zip year  
	
	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post

	*generate the interaction term 
	gen treated_prepost = treated*pre_post

	*Regressions
	quietly eststo zipRR1: reghdfe symbolic_index treated_prepost black_post college_post white_post income_post pop_post [aw=weight_zip], vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipRR2: reghdfe symbolic_index treated_prepost black_post college_post white_post income_post pop_post i.state##c.year [aw=weight_zip], vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo zipAA1: reghdfe affirm treated_prepost black_post college_post white_post income_post pop_post [aw=weight_zip], vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo zipAA2: reghdfe affirm treated_prepost black_post college_post white_post income_post pop_post i.state##c.year [aw=weight_zip], vce(cluster zip) absorb(i.zip i.year) 
	
	esttab zipRR1 zipRR2 zipAA1 zipAA2 using "$main/tables/tablea10-zip.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

************************************************************************************************
* CODE FOR TABLE A11: EFFECT OF REMOVALS FOR NOV 2014 v DEC 2015, ONLY >5 RESPONDENTS (CCES) 
************************************************************************************************

*subset analysis to only those counties/zips with > 5 respondents per wave

set more off

*county-level 

	use "$main/data/CCES_full_county.dta", clear
	
	*only include counties that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015

	egen tag = tag(countycode Unique_ID) 
	egen totalmon = total(tag), by(countycode)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0
	
	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015

	bysort countycode: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	by countycode: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 

	gen logpop = log(pop2010) 
	
	collapse weight_county symbolic_index affirm Black_Pop logpop DemVote12, by(state year region countycode pre_post treated did)
	keep if weight_county > 5
	
	xtset countycode year 
	sum affirm if year==2014
	sum symbolic_index if year==2014
	
	*need to interact covariates with post-treatment indicator
	gen black_post = Black_Pop*pre_post
	gen Dem_post = DemVote12*pre_post
	gen pop_post = logpop*pre_post
	
	*generate the interaction term 
	gen treated_prepost = treated*pre_post

	*Regressions
	quietly eststo countyRR1: reghdfe symbolic_index treated_prepost black_post pop_post Dem_post [aw=weight], vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countyRR2: reghdfe symbolic_index treated_prepost black_post pop_post Dem_post i.state##c.year [aw=weight], vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countyAA1: reghdfe affirm treated_prepost black_post pop_post Dem_post [aw=weight], vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countyAA2: reghdfe affirm treated_prepost black_post pop_post Dem_post i.state##c.year [aw=weight], vce(cluster countycode) absorb(i.countycode i.year)

	esttab countyRR1 countyRR2 countyAA1 countyAA2 using "$main/tables/tablea11-county.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

*Zipcode-level

	use "$main/data/CCES_full_zip.dta", clear

	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015

	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
		
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
			
	collapse symbolic_index affirm percent_black percent_college percent_white logpop med_hh_income weight_zip, by(zip state year region countycode pre_post treated did)
	
	keep if weight_zip > 5

	xtset zip year  
	sum affirm if year==2014
	sum symbolic_index if year==2014
	
	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post

	*generate the interaction term 
	gen treated_prepost = treated*pre_post

	*Regressions
	quietly eststo zipRR1: reghdfe symbolic_index treated_prepost black_post college_post white_post income_post pop_post [aw=weight], vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipRR2: reghdfe symbolic_index treated_prepost black_post college_post white_post income_post pop_post i.state##c.year [aw=weight], vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo zipAA1: reghdfe affirm treated_prepost black_post college_post white_post income_post pop_post [aw=weight], vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo zipAA2: reghdfe affirm treated_prepost black_post college_post white_post income_post pop_post i.state##c.year [aw=weight], vce(cluster zip) absorb(i.zip i.year) 
		
	esttab zipRR1 zipRR2 zipAA1 zipAA2 using "$main/tables/tablea11-zip.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

************************************************************************************************
* CODE FOR TABLE A12: EFFECT OF REMOVALS FOR NOV 2014 v DEC 2015, USING MEDIAN SCORES (CCES) 
************************************************************************************************

	set more off
	set matsize 10000	
	
*county-level

	use "$main/data/CCES_full_county.dta", clear

	*only include counties that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015

	egen tag = tag(countycode Unique_ID) 
	egen totalmon = total(tag), by(countycode)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0
	
	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015

	bysort countycode: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	by countycode: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 

	gen logpop = log(pop2010) 
	
	collapse (median) weight_county symbolic_inde affirm Black_Pop logpop DemVote12, by(state year region countycode pre_post treated did) 
	
	xtset countycode year 
	sum affirm if year==2014
	sum symbolic_index if year==2014
	
	*need to interact covariates with post-treatment indicator
	gen black_post = Black_Pop*pre_post
	gen Dem_post = DemVote12*pre_post
	gen pop_post = logpop*pre_post
	
	*generate the interaction term 
	gen treated_prepost = treated*pre_post

	*Regressions
	quietly eststo countyRR1: reghdfe symbolic_index treated_prepost black_post pop_post Dem_post [aw=weight], vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countyRR2: reghdfe symbolic_index treated_prepost black_post pop_post Dem_post i.state##c.year [aw=weight], vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countyAA1: reghdfe affirm treated_prepost black_post pop_post Dem_post [aw=weight], vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countyAA2: reghdfe affirm treated_prepost black_post pop_post Dem_post i.state##c.year [aw=weight], vce(cluster countycode) absorb(i.countycode i.year)

	esttab countyRR1 countyRR2 countyAA1 countyAA2 using "$main/tables/tablea12-county.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

*zipcode-level

	use "$main/data/CCES_full_zip.dta", clear
	
	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015

	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
		
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
			
	collapse (median) symbolic_index affirm percent_black percent_college percent_white logpop med_hh_income weight_zip, by(zip state year region countycode pre_post treated did)
	

	xtset zip year  
	sum affirm if year==2014
	sum symbolic_index if year==2014
	
	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post

	*generate the interaction term 
	gen treated_prepost = treated*pre_post
	
	*Regressions
	quietly eststo zipRR1: reghdfe symbolic_index treated_prepost black_post college_post white_post income_post pop_post [aw=weight], vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipRR2: reghdfe symbolic_index treated_prepost black_post college_post white_post income_post pop_post i.state##c.year [aw=weight], vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo zipAA1: reghdfe affirm treated_prepost black_post college_post white_post income_post pop_post [aw=weight], vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo zipAA2: reghdfe affirm treated_prepost black_post college_post white_post income_post pop_post i.state##c.year [aw=weight], vce(cluster zip) absorb(i.zip i.year) 
		
	esttab zipRR1 zipRR2 zipAA1 zipAA2 using "$main/tables/tablea12-zip.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

************************************************************************************************
* CODE FOR TABLE A13: EFFECT OF REMOVALS FOR NOV 2014 v DEC 2015, ADDITIONAL CONTROLS (CCES) 
************************************************************************************************

	use "$main/data/CCES_full_county.dta", clear

	*only include counties that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
		
	egen tag = tag(countycode Unique_ID) 
	egen totalmon = total(tag), by(countycode)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0
	
	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015

	bysort countycode: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	by countycode: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 

	gen logpop = log(pop2010) 
		
	collapse symbolic_index affirm Black_Pop logpop DemVote12 college_survey survey_black survey_white liberal conserv, by(state year region countycode pre_post treated did)
	
	xtset countycode year
	*keep only counties with two observations
	by countycode, sort: egen obs = count(year)
	drop if obs <2
	drop obs
	
	*generate a variable that is change in percent black, white, educated, liberal, conservative between 2014 and 2015 
	bysort countycode: gen change_black = survey_black - survey_black[_n-1] 
	bysort countycode : replace change_black = change_black[_N] 
	
	bysort countycode: gen change_white = survey_white - survey_white[_n-1] 
	bysort countycode : replace change_white = change_white[_N] 

	bysort countycode: gen change_college = college_survey - college_survey[_n-1] 
	bysort countycode : replace change_college = change_college[_N] 
	
	bysort countycode: gen change_liberal = liberal - liberal[_n-1] 
	bysort countycode : replace change_liberal = change_liberal[_N] 

	bysort countycode: gen change_conserv = conserv - conserv[_n-1] 
	bysort countycode : replace change_conserv = change_conserv[_N] 

	*need to interact covariates with post-treatment indicator
	gen black_post = Black_Pop*pre_post
	gen Dem_post = DemVote12*pre_post
	gen pop_post = logpop*pre_post
	gen post_change_black = change_black*pre_post
	gen post_change_white = change_white*pre_post
	gen post_change_college = change_college*pre_post
	gen post_change_liberal = change_liberal*pre_post
	gen post_change_conserv = change_conserv*pre_post
	
	*generate the interaction term 
	gen treated_prepost = treated*pre_post
	
	*Regressions
	quietly eststo countyRR1: reghdfe symbolic_index treated_prepost black_post pop_post Dem_post post_change_black post_change_white post_change_college post_change_liberal post_change_conserv, vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countyRR2: reghdfe symbolic_index treated_prepost black_post pop_post Dem_post post_change_black post_change_white post_change_college post_change_liberal post_change_conserv i.state##c.year, vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countyAA1: reghdfe affirm treated_prepost black_post pop_post Dem_post post_change_black post_change_white post_change_college post_change_liberal post_change_conserv, vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countyAA2: reghdfe affirm treated_prepost black_post pop_post Dem_post post_change_black post_change_white post_change_college post_change_liberal post_change_conserv i.state##c.year, vce(cluster countycode) absorb(i.countycode i.year)

	esttab countyRR1 countyRR2 countyAA1 countyAA2 using "$main/tables/tablea13-county.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

*zipcode-level

	use "$main/data/CCES_full_zip.dta", clear

	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015

	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
		
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
			
	collapse symbolic_index affirm percent_black percent_college percent_white logpop med_hh_income college_survey survey_black survey_white liberal conserv, by(zip state year region countycode pre_post treated did)
	
	xtset zip year  
	by zip, sort: egen obs = count(year)
	drop if obs <2
	drop obs

	*generate a variable that is change in percent black, white, educated, liberal, conservative between 2014 and 2015 
	bysort zip: gen change_black = survey_black - survey_black[_n-1] 
	bysort zip : replace change_black = change_black[_N] 
	
	bysort zip: gen change_white = survey_white - survey_white[_n-1] 
	bysort zip : replace change_white = change_white[_N] 

	bysort zip: gen change_college = college_survey - college_survey[_n-1] 
	bysort zip : replace change_college = change_college[_N] 
	
	bysort zip: gen change_liberal = liberal - liberal[_n-1] 
	bysort zip : replace change_liberal = change_liberal[_N] 

	bysort zip: gen change_conserv = conserv - conserv[_n-1] 
	bysort zip : replace change_conserv = change_conserv[_N] 

	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post
	gen post_change_black = change_black*pre_post
	gen post_change_white = change_white*pre_post
	gen post_change_college = change_college*pre_post
	gen post_change_liberal = change_liberal*pre_post
	gen post_change_conserv = change_conserv*pre_post

	*generate the interaction term 
	gen treated_prepost = treated*pre_post
	
	*Regressions
	quietly eststo zipRR1: reghdfe symbolic_index treated_prepost black_post college_post white_post income_post pop_post post_change_black post_change_white post_change_college post_change_liberal post_change_conserv, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipRR2: reghdfe symbolic_index treated_prepost black_post college_post white_post income_post pop_post post_change_black post_change_white post_change_college post_change_liberal post_change_conserv i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo zipAA1: reghdfe affirm treated_prepost black_post college_post white_post income_post pop_post post_change_black post_change_white post_change_college post_change_liberal post_change_conserv, vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo zipAA2: reghdfe affirm treated_prepost black_post college_post white_post income_post pop_post post_change_black post_change_white post_change_college post_change_liberal post_change_conserv i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 
		
	esttab zipRR1 zipRR2 zipAA1 zipAA2 using "$main/tables/tablea13-zip.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace
	
***********************************************************************************************
* CODE FOR TABLE A14: EFFECT OF REMOVALS FOR NOV 2014 v DEC 2015, STATE-LOCAL (CCES) 
************************************************************************************************	
	set more off
		
*Zipcode-level; no state restrictions
	
	use "$main/data/CCES_full_zip.dta", clear
	
	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
	keep if State_Restrictions==0
	
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
	
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm percent_black percent_college percent_white logpop med_hh_income, by(zip state year region countycode pre_post treated did)
	
	xtset zip year  
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post

	
	sum symbolic_index if year==2014, detail
	*0.63 mean, median of 0.63 [mean of dependent variable reported in Table A14]
	sum affirm if year==2014, detail
	*0.37 mean, median of 0.33 [mean of dependent variable reported in Table A14]

	*generate the interaction term 
	gen treated_prepost = treated*pre_post

	*Regressions
			
	quietly eststo zipRR1: reghdfe symbolic_index treated_prepost percent_black percent_college percent_white med_hh_income logpop, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipRR2: reghdfe symbolic_index treated_prepost black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipAA1: reghdfe affirm treated_prepost percent_black percent_college percent_white med_hh_income logpop, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipAA2: reghdfe affirm treated_prepost black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year)

	esttab zipRR1 zipRR2 zipAA1 zipAA2 using "$main/tables/tablea14-zip-panelA.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

*zipcode-level; with state restrictions

	use "$main/data/CCES_full_zip.dta", clear
	
	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
	keep if State_Restrictions==1
	
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
	
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm percent_black percent_college percent_white logpop med_hh_income, by(zip state year region countycode pre_post treated did)
	
	xtset zip year  
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post

	
	sum symbolic_index if year==2014, detail
	*0.63 mean, median of 0.63 [mean of dependent variable reported in Table A14]
	sum affirm if year==2014, detail
	*0.37 mean, median of 0.33 [mean of dependent variable reported in Table A14]

	*generate the interaction term 
	gen treated_prepost = treated*pre_post

	*Regresssions
	quietly eststo zipRR1: reghdfe symbolic_index treated_prepost percent_black percent_college percent_white med_hh_income logpop, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipRR2: reghdfe symbolic_index treated_prepost black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipAA1: reghdfe affirm treated_prepost percent_black percent_college percent_white med_hh_income logpop, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipAA2: reghdfe affirm treated_prepost black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year)

	esttab zipRR1 zipRR2 zipAA1 zipAA2 using "$main/tables/tablea14-zip-panelB.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

**************************************************************************************
* CODE FOR TABLE A15: EFFECT OF REMOVALS FOR DEC 2016 v JULY 2017, STATE-LOCAL (VSG) 
**************************************************************************************

*county-level, no restrictions

	use "$main/data/VSG_full_county.dta", clear
	keep if year == 2016 | year == 2017
	keep if State_Restrictions==0

	egen tag = tag(countycode Unique_ID) 
	egen totalmon = total(tag), by(countycode)
	
	ta totalmon if monthly_date_confed<tm(2016m12)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_vsg == tm(2017m7) if !missing(monthly_date_vsg)
	
	*treatment period group: monuments removed after December 2016 for 2016 VSG and before July 2017 for 2017 VSG
	*control group: monuments still active after July 2017
	
	bysort countycode: gen byte removed = inrange(monthly_date_confed, tm(2017m1), tm(2017m7))
	by countycode: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2016m12)
	gen did = pre_post*treated 

	collapse ft_blacks age race liberal conserv male educ, by(id state countycode year pre_post treated did)
	
	gen age2 = age*age
	
	xtset id year 
	summarize ft_blacks if year==2016, detail
	*0.72 mean of dependent variable reported in Table
	
	*generate the interaction term 
	gen treated_prepost = treated*pre_post
	
	*Regressions
	quietly eststo countyFT1: reghdfe ft_blacks treated_prepost age age2 race liberal educ male liberal conserv, vce(cluster county) absorb(i.id i.year)
	quietly eststo countyFT2: reghdfe ft_blacks treated_prepost age age2 race liberal educ male liberal conserv i.state##c.year, vce(cluster county) absorb(i.id)
	

*county-level, with restrictions

	use "$main/data/VSG_full_county.dta", clear
	keep if year == 2016 | year == 2017
	keep if State_Restrictions==1

	egen tag = tag(countycode Unique_ID) 
	egen totalmon = total(tag), by(countycode)
	
	ta totalmon if monthly_date_confed<tm(2016m12)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_vsg == tm(2017m7) if !missing(monthly_date_vsg)
	
	*treatment period group: monuments removed after December 2016 for 2016 VSG and before July 2017 for 2017 VSG
	*control group: monuments still active after July 2017
	
	bysort countycode: gen byte removed = inrange(monthly_date_confed, tm(2017m1), tm(2017m7))
	by countycode: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2016m12)
	gen did = pre_post*treated 

	collapse ft_blacks age race liberal conserv male educ, by(id state countycode year pre_post treated did)
	
	gen age2 = age*age
	
	xtset id year 
	summarize ft_blacks if year==2016, detail
	*0.72 mean of dependent variable reported in Table

	*generate the interaction term 
	gen treated_prepost = treated*pre_post
	
	*Regressions
	quietly eststo countyFT3: reghdfe ft_blacks treated_prepost age age2 race liberal educ male liberal conserv, vce(cluster county) absorb(i.id i.year)
	quietly eststo countyFT4: reghdfe ft_blacks treated_prepost age age2 race liberal educ male liberal conserv i.state##c.year, vce(cluster county) absorb(i.id)

	esttab countyFT1 countyFT2 countyFT3 countyFT4 using "$main/tables/tablea15.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace


*******************************************************************************
* CODE FOR TABLE A16: EFFECT OF REMOVALS, NO. OF SYMBOLS/CONTEXTUAL UNIT, CCES
*******************************************************************************

*county-level 
	set more off
	use "$main/data/CCES_full_county.dta", clear
	
	*only include counties that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015

	egen tag = tag(countycode Unique_ID) 
	egen totalmon = total(tag), by(countycode)

	ta totalmon if monthly_date_confed<tm(2015m7)

	*by countycode: egen weight = count(Unique_ID)

	unique Unique_ID, by(countycode) gen(weight)
	
	*need to replace all the missings with the same value by countycode to make sure they are counted

	qui bysort countycode (weight): replace weight=weight[1]
	
	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015

	bysort countycode: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	by countycode: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 

	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm Black_Pop logpop DemVote12 weight, by(state year region countycode pre_post treated did)
	
	xtset countycode year 
	
	*need to interact covariates with post-treatment indicator
	gen black_post = Black_Pop*pre_post
	gen Dem_post = DemVote12*pre_post
	gen pop_post = logpop*pre_post
	gen weight_post = weight*pre_post
	
	*generate the interaction term 
	gen treated_prepost = treated*pre_post

	*regressions
	quietly eststo countyRR: reghdfe symbolic_index treated_prepost black_post pop_post Dem_post weight_post i.state##c.year, vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countyAA: reghdfe affirm treated_prepost black_post pop_post Dem_post weight_post i.state##c.year, vce(cluster countycode) absorb(i.countycode i.year)

*zipcode-level 

	use "$main/data/CCES_full_zip.dta", clear

	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015

	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015

	*generate a weight for number of symbols per zipcode
	unique Unique_ID, by(countycode) gen(weight)
	
	*need to replace all the missings with the same value by countycode to make sure they are counted

	qui bysort countycode (weight): replace weight=weight[1]
			
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm percent_black percent_college percent_white logpop med_hh_income weight, by(zip state year region countycode pre_post treated did)
	
	xtset zip year  
	
	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post
	gen weight_post = weight*pre_post

	
	*generate the interaction term 
	gen treated_prepost = treated*pre_post
	
	*regression
	quietly eststo zipRR: reghdfe symbolic_index treated_prepost black_post college_post white_post income_post pop_post weight_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo zipAA: reghdfe affirm treated_prepost black_post college_post white_post income_post pop_post weight_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 

	esttab countyRR countyAA zipRR zipAA using "$main/tables/tablea16.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace


***********************************************************************************
* CODE FOR FIGURE A.5: DISTANCE-BASED CONTEXTUAL UNITS, CCES NOV 2014 vs. DEC 2015
***********************************************************************************
	
	set more off
	local geo_level "fivemiles tenmiles twentymiles fiftymiles seventyfivemiles onehundredmiles" 
	local n_models: word count `geo_level'
	
	forval i=1/`n_models' {

		***************
		* GLOBALS	 *
		***************	
		
		global geo_level `: word `i' of `geo_level''

		use "$main/data/CCES_full_${geo_level}.dta", clear
	
		keep if year == 2014 | year == 2015
		
		egen tag = tag(countycode Unique_ID) 
		egen totalmon = total(tag), by(countycode)

		ta totalmon if monthly_date_confed<tm(2015m7)
		
		*only depends on time
		gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
		
		*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
		*control group: monuments still active after December 2015

		bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
		
		*at least ONE of the monuments removed so label all rows with that zipcode as treated 
		by zip: egen treated = max(removed)
		
		drop if monthly_date_confed<=tm(2014m2)
		gen did = pre_post*treated 
		
		gen logpop = log(pop2010) 
		
		collapse (median) weight_zip symbolic_index affirm percent_black percent_college med_hh_income percent_white logpop, by(zip state year region countycode pre_post treated did)
	
		xtset zip year  
		
		*need to interact covariates with post-treatment indicator
		gen black_post = percent_black*pre_post
		gen white_post = percent_white*pre_post
		gen college_post = percent_college*pre_post
		gen income_post = med_hh_income*pre_post
		gen pop_post = logpop*pre_post

		*main with zip-level controls 
		
		local regressions = 1 
		if `regressions' {
		quietly eststo affirm_$geo_level: reghdfe affirm i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 
		quietly eststo rr_$geo_level: reghdfe symbolic_index i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 


			}	
	}
	
	#delimit;
	coefplot (rr_fivemiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(rr_tenmiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(rr_twentymiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(rr_fiftymiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(rr_seventyfivemiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(rr_onehundredmiles, mcolor(black) ciopts(lcolor(black)) lcol(black)), keep(1.treated#1.pre_post)
	legend(off) mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "+", "")))))
	vertical drop(1.treated 1.pre_post _cons) yline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white))
	ytitle("Diff-in-Diff Coefficients" " ", size(small))
	title("Racial Resentment", size(small) color(black))
	lcol(black)
	ylab(-.5(0.1).5, nogrid) xlabel("") name(A);
	#delimit cr

	#delimit;
	coefplot (affirm_fivemiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(affirm_tenmiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(affirm_twentymiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(affirm_fiftymiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(affirm_seventyfivemiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(affirm_onehundredmiles, mcolor(black) ciopts(lcolor(black)) lcol(black)), keep(1.treated#1.pre_post)
	legend(off) mlabposition(1)
	mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "+", "")))))
	vertical drop(1.treated 1.pre_post _cons) yline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white))
	ytitle("" " ")
	title("Support for Affirmative Action", size(small) color(black))
	lcol(black)
	ylab(-.5(0.1).5, nogrid) xlabel("") name(B);
	#delimit cr
	
	#delimit;
	graph combine A B, xsize(8) rows(1) cols(2) 
	note("+ p < .1, * p < .05, ** p < .01, *** p < .001", size(vsmall))
	plotregion(fcolor(white)) graphregion(fcolor(white));
	#delimit cr
	graph export "$main/figures/figure-a5-appendix.pdf", replace
	
	*note that x-axis labels were added manually to the figure with the graph editor
	
	graph drop A B
	
***********************************************************************************
* CODE FOR FIGURE A.6: DISTANCE-BASED CONTEXTUAL UNITS, VSG DEC 2016 vs. JULY 2016
***********************************************************************************

	set more off
	local geo_level "fivemiles tenmiles twentymiles fiftymiles seventyfivemiles onehundredmiles" 
	local n_models: word count `geo_level'
	
	forval i=1/`n_models' {

		***************
		* GLOBALS	 *
		***************	
		
		global geo_level `: word `i' of `geo_level''

		use "$main/data/VSG_full_${geo_level}.dta", clear

		keep if year == 2016 | year == 2017
		
		egen tag = tag(zip Unique_ID) 
		egen totalmon = total(tag), by(zip)
	
		ta totalmon if monthly_date_confed<tm(2016m12)
		drop if totalmon==0
			
		*only depends on time
		gen byte pre_post= monthly_date_vsg == tm(2017m7) if !missing(monthly_date_vsg)
		
		bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2017m1), tm(2017m7))
		by zip: egen treated = max(removed)
		
		drop if monthly_date_confed<=tm(2016m12) 

		gen did = pre_post*treated 
		
		gen logpop = log(pop2010) 
		gen age2 = age*age
		
		collapse (median) ft_blacks age age2 race liberal conserv educ male, by(id state countycode year pre_post treated did zip)

		xtset id year  
		
		local regressions = 1 
		if `regressions' {
		quietly eststo ftblack_$geo_level: reghdfe ft_blacks i.treated##i.pre_post age age2 race liberal conserv  educ male i.state##c.year, vce(cluster countycode) absorb(i.id)


			}	
	}
	
	
	#delimit;
	coefplot (ftblack_fivemiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(ftblack_tenmiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(ftblack_twentymiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(ftblack_fiftymiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(ftblack_seventyfivemiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(ftblack_onehundredmiles, mcolor(black) ciopts(lcolor(black)) lcol(black)), keep(1.treated#1.pre_post)
	legend(off) mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "+", "")))))
	vertical drop(1.treated 1.pre_post _cons) yline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white))
	ytitle("Diff-in-Diff Coefficients" " ", size(small))
	title("Feeling Thermometer: Toward Blacks", size(small) color(black))
	lcol(black)
	ylab(-.3(0.1).3, nogrid) xlabel("") name(A);
	#delimit cr
	graph export "$main/figures/figure-a6-appendix.pdf", replace

	graph drop A

***********************************************************************************
* CODE FOR FIGURE A.7: PLACEBO TESTS WITH OTHER CCES POLITICAL OPINION QUESTIONS
***********************************************************************************

	set more off
	set matsize 10000	

*county-level 

	use "$main/data/CCES_full_county.dta", clear

	*only include counties that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015	
	

	egen tag = tag(countycode Unique_ID) 
	egen totalmon = total(tag), by(countycode)

	ta totalmon if monthly_date_confed<tm(2015m7)
	*none with zero monuments at the start of June 2015 so don't drop any counties from sammple

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
	
	bysort countycode: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	by countycode: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
	
	#delimit ;
	collapse symbolic_index affirm religion_important 
	 clean_air_act
	grant_status_immigration  employers_decline_abortion abortion_rape 
	raise_fuel_efficiency state_require_min_renewable epa_regulate_c02 identify_deport fine_business_immigration 
	border_patrols_immigration national_econ
	Black_Pop logpop DemVote12, by(state year region countycode pre_post treated did)
	; 
	#delimit cr
	
	xtset countycode year  

	*need to interact covariates with post-treatment indicator
	gen black_post = Black_Pop*pre_post
	gen Dem_post = DemVote12*pre_post
	gen pop_post = logpop*pre_post

	**Regressions
	quietly eststo countynocontrolA: reghdfe religion_important i.treated##i.pre_post black_post pop_post Dem_post, vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countynocontrolC: reghdfe employers_decline_abortion  i.treated##i.pre_post black_post pop_post Dem_post, vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countynocontrolD: reghdfe abortion_rape i.treated##i.pre_post black_post pop_post Dem_post, vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countynocontrolE: reghdfe clean_air_act i.treated##i.pre_post black_post pop_post Dem_post, vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countynocontrolF: reghdfe epa_regulate_c02  i.treated##i.pre_post black_post pop_post Dem_post, vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countynocontrolG: reghdfe raise_fuel_efficiency  i.treated##i.pre_post black_post pop_post Dem_post, vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countynocontrolH: reghdfe state_require_min_renewable  i.treated##i.pre_post black_post pop_post Dem_post, vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countynocontrolI: reghdfe grant_status_immigration  i.treated##i.pre_post black_post pop_post Dem_post, vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countynocontrolJ: reghdfe identify_deport  i.treated##i.pre_post black_post pop_post Dem_post, vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countynocontrolK: reghdfe fine_business_immigration  i.treated##i.pre_post black_post pop_post Dem_post, vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countynocontrolL: reghdfe border_patrols_immigration  i.treated##i.pre_post black_post pop_post Dem_post, vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countynocontrolM: reghdfe national_econ  i.treated##i.pre_post black_post pop_post Dem_post, vce(cluster countycode) absorb(i.countycode i.year)

	quietly eststo countycontrolA: reghdfe religion_important i.treated##i.pre_post black_post pop_post Dem_post i.state##c.year, vce(cluster countycode) absorb(i.countycode)
	quietly eststo countycontrolC: reghdfe employers_decline_abortion i.treated##i.pre_post black_post pop_post Dem_post i.state##c.year, vce(cluster countycode) absorb(i.countycode)
	quietly eststo countycontrolD: reghdfe abortion_rape i.treated##i.pre_post black_post pop_post Dem_post i.state##c.year, vce(cluster countycode) absorb(i.countycode)
	quietly eststo countycontrolE: reghdfe clean_air_act i.treated##i.pre_post black_post pop_post Dem_post i.state##c.year, vce(cluster countycode) absorb(i.countycode)
	quietly eststo countycontrolF: reghdfe epa_regulate_c02 i.treated##i.pre_post black_post pop_post Dem_post i.state##c.year, vce(cluster countycode) absorb(i.countycode)
	quietly eststo countycontrolG: reghdfe raise_fuel_efficiency i.treated##i.pre_post black_post pop_post Dem_post i.state##c.year, vce(cluster countycode) absorb(i.countycode)
	quietly eststo countycontrolH: reghdfe state_require_min_renewable i.treated##i.pre_post black_post pop_post Dem_post i.state##c.year, vce(cluster countycode) absorb(i.countycode)
	quietly eststo countycontrolI: reghdfe grant_status_immigration i.treated##i.pre_post black_post pop_post Dem_post i.state##c.year, vce(cluster countycode) absorb(i.countycode)
	quietly eststo countycontrolJ: reghdfe identify_deport i.treated##i.pre_post black_post pop_post Dem_post i.state##c.year, vce(cluster countycode) absorb(i.countycode)
	quietly eststo countycontrolK: reghdfe fine_business_immigration i.treated##i.pre_post black_post pop_post Dem_post i.state##c.year, vce(cluster countycode) absorb(i.countycode)
	quietly eststo countycontrolL: reghdfe border_patrols_immigration i.treated##i.pre_post black_post pop_post Dem_post i.state##c.year, vce(cluster countycode) absorb(i.countycode)
	quietly eststo countycontrolM: reghdfe national_econ i.treated##i.pre_post black_post pop_post Dem_post i.state##c.year, vce(cluster countycode) absorb(i.countycode)

*Zipcode-level	

	use "$main/data/CCES_full_zip.dta", clear

	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
		
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0
	
	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
	
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
	
	#delimit ;
	collapse symbolic_index affirm religion_important 
	 clean_air_act
	increase_police_immigration grant_status_immigration  employers_decline_abortion abortion_rape 
	raise_fuel_efficiency state_require_min_renewable epa_regulate_c02 identify_deport fine_business_immigration 
	border_patrols_immigration national_econ percent_black 
	percent_college med_hh_income percent_white logpop, by(zip state year region countycode pre_post treated did)
	; 
	#delimit cr
	
	xtset zip year 
	
	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post

	*Regressions

	quietly eststo zipnocontrolA: reghdfe religion_important i.treated##i.pre_post black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipnocontrolC: reghdfe employers_decline_abortion i.treated##i.pre_post black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipnocontrolD: reghdfe abortion_rape i.treated##i.pre_post black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipnocontrolE: reghdfe clean_air_act i.treated##i.pre_post black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipnocontrolF: reghdfe epa_regulate_c02 i.treated##i.pre_post black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipnocontrolG: reghdfe raise_fuel_efficiency i.treated##i.pre_post black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipnocontrolH: reghdfe state_require_min_renewable i.treated##i.pre_post black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipnocontrolI: reghdfe grant_status_immigration i.treated##i.pre_post black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipnocontrolJ: reghdfe identify_deport i.treated##i.pre_post black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipnocontrolK: reghdfe fine_business_immigration i.treated##i.pre_post black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipnocontrolL: reghdfe border_patrols_immigration i.treated##i.pre_post black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipnocontrolM: reghdfe national_econ i.treated##i.pre_post black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)

	quietly eststo zipcontrolA: reghdfe religion_important i.treated##i.pre_post black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)
	quietly eststo zipcontrolC: reghdfe employers_decline_abortion i.treated##i.pre_post black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)
	quietly eststo zipcontrolD: reghdfe abortion_rape i.treated##i.pre_post black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)
	quietly eststo zipcontrolE: reghdfe clean_air_act i.treated##i.pre_post black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)
	quietly eststo zipcontrolF: reghdfe epa_regulate_c02 i.treated##i.pre_post black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)
	quietly eststo zipcontrolG: reghdfe raise_fuel_efficiency i.treated##i.pre_post black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)
	quietly eststo zipcontrolH: reghdfe state_require_min_renewable i.treated##i.pre_post black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)
	quietly eststo zipcontrolI: reghdfe grant_status_immigration i.treated##i.pre_post black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)
	quietly eststo zipcontrolJ: reghdfe identify_deport i.treated##i.pre_post black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)
	quietly eststo zipcontrolK: reghdfe fine_business_immigration i.treated##i.pre_post black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)
	quietly eststo zipcontrolL: reghdfe border_patrols_immigration i.treated##i.pre_post black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)
	quietly eststo zipcontrolM: reghdfe national_econ i.treated##i.pre_post black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)


	*Placebo Graphs
		
	#delimit;
	coefplot (countynocontrolA, mcolor(black) ciopts(lcolor(black) lcol(black))) 
	(zipnocontrolA, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(countycontrolA, mcolor(black) ciopts(lcolor(black)))
	(zipcontrolA, mcolor(gray) ciopts(lcolor(gray) lcol(gray))),  keep(1.treated#1.pre_post)
	xline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white)) 
	mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "", ""))))) 
	xlab(-1(0.2)1, nogrid) msymbol(d) mfcolor(white) 
	legend(order(1 "county" 3 "zipcode") ring(0) position(11) bmargin(small) size(vsmall) col(1))
	ylab("") title("Placebo: Importance of Religion", size(vsmall) color(black)) name(A); 
	#delimit cr
	
	#delimit;
	coefplot (countynocontrolC, mcolor(black) ciopts(lcolor(black) lcol(black))) 
	(zipnocontrolC, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(countycontrolC, mcolor(black) ciopts(lcolor(black)))
	(zipcontrolC, mcolor(gray) ciopts(lcolor(gray) lcol(gray))),  keep(1.treated#1.pre_post)
	xline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white)) 
	mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "", ""))))) legend(off)
	xlab(-1(0.5)4, nogrid) msymbol(d) mfcolor(white) 
	ylab("") title("Placebo: Allow Employer to Decline Abortion", size(vsmall) color(black)) name(C); 
	#delimit cr
	
	#delimit;
	coefplot (countynocontrolD, mcolor(black) ciopts(lcolor(black) lcol(black))) 
	(zipnocontrolD, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(countycontrolD, mcolor(black) ciopts(lcolor(black)))
	(zipcontrolD, mcolor(gray) ciopts(lcolor(gray) lcol(gray))),  keep(1.treated#1.pre_post)
	xline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white)) 
	mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "", ""))))) legend(off)
	xlab(-1(0.2)1, nogrid) msymbol(d) mfcolor(white) 
	ylab("") title("Placebo: Permit Abortion Only if Rape", size(vsmall) color(black)) name(D); 
	#delimit cr
	
	
	#delimit;
	coefplot (countynocontrolE, mcolor(black) ciopts(lcolor(black) lcol(black))) 
	(zipnocontrolE, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(countycontrolE, mcolor(black) ciopts(lcolor(black)))
	(zipcontrolE, mcolor(gray) ciopts(lcolor(gray) lcol(gray))),  keep(1.treated#1.pre_post)
	xline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white)) 
	mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "", ""))))) legend(off)
	xlab(-1(0.2)1, nogrid) msymbol(d) mfcolor(white)
	ylab("") title("Placebo: EPA Strengthen Enforcement of Clean Air Act", size(vsmall) color(black)) name(E); 
	#delimit cr
	
	#delimit;
	coefplot (countynocontrolF, mcolor(black) ciopts(lcolor(black) lcol(black))) 
	(zipnocontrolF, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(countycontrolF, mcolor(black) ciopts(lcolor(black)))
	(zipcontrolF, mcolor(gray) ciopts(lcolor(gray) lcol(gray))),  keep(1.treated#1.pre_post)
	xline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white)) 
	mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "", ""))))) legend(off)
	xlab(-1(0.2)1, nogrid) msymbol(d) mfcolor(white) 
	ylab("") title("Placebo: EPA Regulate C02 Emissions", size(vsmall) color(black)) name(F); 
	#delimit cr
	
	#delimit;
	coefplot (countynocontrolG, mcolor(black) ciopts(lcolor(black) lcol(black))) 
	(zipnocontrolG, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(countycontrolG, mcolor(black) ciopts(lcolor(black)))
	(zipcontrolG, mcolor(gray) ciopts(lcolor(gray) lcol(gray))),  keep(1.treated#1.pre_post)
	xline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white)) 
	mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "", ""))))) legend(off)
	xlab(-1(0.2)1, nogrid) msymbol(d) mfcolor(white) 
	ylab("") title("Placebo: Raise Fuel Efficiency for Avg Auto", size(vsmall) color(black)) name(G); 
	#delimit cr
	
	#delimit;
	coefplot (countynocontrolH, mcolor(black) ciopts(lcolor(black) lcol(black))) 
	(zipnocontrolH, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(countycontrolH, mcolor(black) ciopts(lcolor(black)))
	(zipcontrolH, mcolor(gray) ciopts(lcolor(gray) lcol(gray))),  keep(1.treated#1.pre_post)
	xline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white)) 
	mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "", ""))))) legend(off)
	xlab(-1(0.2)1, nogrid) msymbol(d) mfcolor(white) 
	ylab("") title("Placebo: States Require Min Amount of Renew Fuels", size(vsmall) color(black)) name(H); 
	#delimit cr
	
	#delimit;
	coefplot (countynocontrolI, mcolor(black) ciopts(lcolor(black) lcol(black))) 
	(zipnocontrolI, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(countycontrolI, mcolor(black) ciopts(lcolor(black)))
	(zipcontrolI, mcolor(gray) ciopts(lcolor(gray) lcol(gray))),  keep(1.treated#1.pre_post)
	xline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white)) 
	mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "", ""))))) legend(off)
	xlab(-1(0.2)1, nogrid) msymbol(d) mfcolor(white)
	ylab("") title("Placebo: Grant Legal Status to All Illegal Immigrants", size(vsmall) color(black)) name(I); 
	#delimit cr
	
	#delimit;
	coefplot (countynocontrolJ, mcolor(black) ciopts(lcolor(black) lcol(black))) 
	(zipnocontrolJ, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(countycontrolJ, mcolor(black) ciopts(lcolor(black)))
	(zipcontrolJ, mcolor(gray) ciopts(lcolor(gray) lcol(gray))),  keep(1.treated#1.pre_post)
	xline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white)) 
	mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "", ""))))) legend(off)
	xlab(-1(0.2)1, nogrid) msymbol(d) mfcolor(white) 
	ylab("") title("Placebo: Identify and Deport Illegal Immigrants", size(vsmall) color(black)) name(J); 
	#delimit cr
		
	#delimit;
	coefplot (countynocontrolK, mcolor(black) ciopts(lcolor(black) lcol(black))) 
	(zipnocontrolK, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(countycontrolK, mcolor(black) ciopts(lcolor(black)))
	(zipcontrolK, mcolor(gray) ciopts(lcolor(gray) lcol(gray))),  keep(1.treated#1.pre_post)
	xline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white)) 
	mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "", ""))))) legend(off)
	xlab(-1(0.2)1, nogrid) msymbol(d) mfcolor(white) 
	ylab("") title("Placebo: Fine US Businesses that Hire Illegal Immigrants", size(vsmall) color(black)) name(K); 
	#delimit cr
	
	#delimit;
	coefplot (countynocontrolL, mcolor(black) ciopts(lcolor(black) lcol(black))) 
	(zipnocontrolL, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(countycontrolL, mcolor(black) ciopts(lcolor(black)))
	(zipcontrolL, mcolor(gray) ciopts(lcolor(gray) lcol(gray))),  keep(1.treated#1.pre_post)
	xline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white)) 
	mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "", ""))))) legend(off)
	xlab(-1(0.2)1, nogrid) msymbol(d) mfcolor(white) 
	ylab("") title("Placebo: Increase the Number of Border Patrols", size(vsmall) color(black)) name(L); 
	#delimit cr
	
	#delimit;
	coefplot (countynocontrolM, mcolor(black) ciopts(lcolor(black) lcol(black))) 
	(zipnocontrolM, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(countycontrolM, mcolor(black) ciopts(lcolor(black)))
	(zipcontrolM, mcolor(gray) ciopts(lcolor(gray) lcol(gray))),  keep(1.treated#1.pre_post)
	xline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white)) 
	mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "", "")))))
	xlab(-1(0.2)1, nogrid) msymbol(d) mfcolor(white) legend(off)
	ylab("") title("Placebo: State of the National Economy", size(vsmall) color(black)) name(M); 
	#delimit cr
	
	graph combine A C D E F G H I J K L M, row(4) graphregion(color(white)) note("* p < .05, ** p < .01, *** p < .001", size(vsmall))
	name(combined, replace)
	graph export "$main/figures/figure-a7-appendix.pdf", replace

	graph drop A C D E F G H I J K L M
	
***********************************************************************************
* CODE FOR FIGURE A.8: NOV 2014 vs DEC 2015 RESULTS FOR WHITES AND BLACKS
***********************************************************************************

	set more off

*Zipcode-level: whites

	use "$main/data/CCES_whites_zip.dta", clear

	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
		
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0
	
	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
	
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
	
	collapse (median) symbolic_index affirm religion_important percent_black percent_college med_hh_income percent_white logpop, by(zip state year region countycode pre_post treated did)
	
	xtset zip year 
	
	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post
	
	*Regressions
	quietly eststo zipnocontrolW: reghdfe symbolic_index i.treated##i.pre_post black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo zipcontrolW: reghdfe symbolic_index i.treated##i.pre_post black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip) 
	quietly eststo zipnocontrolAW: reghdfe affirm i.treated##i.pre_post black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipcontrolAW: reghdfe affirm i.treated##i.pre_post black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)

*Zipcode-level: Blacks
	
	use "$main/data/CCES_blacks_zip.dta", clear
	
	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
		
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0
	
	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
	
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
	
	collapse (median) symbolic_index affirm religion_important percent_black percent_college med_hh_income percent_white logpop, by(zip state year region countycode pre_post treated did)
	
	xtset zip year 
	
	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post
	
	*Regressions
	quietly eststo zipnocontrolB: reghdfe symbolic_index i.treated##i.pre_post black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipcontrolB: reghdfe symbolic_index i.treated##i.pre_post black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)
	quietly eststo zipnocontrolAB: reghdfe affirm i.treated##i.pre_post black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipcontrolAB: reghdfe affirm i.treated##i.pre_post black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)

	*combine into graph
	
	#delimit;
	coefplot 
	(zipnocontrolW, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(zipnocontrolB, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(zipcontrolW, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(zipcontrolB, mcolor(black) ciopts(lcolor(black)) lcol(black)), keep(1.treated#1.pre_post) 
	xline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white)) 
	mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "+", "")))))
	xlab(-.4(0.1).7, nogrid) msymbol(d) mfcolor(white) legend(order(1 "Whites" 3 "Blacks") ring(0) position(3) bmargin(large) size(vsmall) col(1))
	ylab("") title("Racial Resentment", size(medium) color(black)) name(A);
	#delimit cr

	#delimit;
	coefplot 
	(zipnocontrolAW, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(zipnocontrolAB, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(zipcontrolAW, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(zipcontrolAB, mcolor(black) ciopts(lcolor(black)) lcol(black)), keep(1.treated#1.pre_post) 
	xline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white)) 
	mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "+", "")))))
	xlab(-.4(0.1).7, nogrid) msymbol(d) mfcolor(white) legend(off)
	ylab("") title("Affirmative Action", size(medium) color(black)) name(B); 
	#delimit cr
	
	#delimit;
	graph combine A B, xsize(8) rows(1) cols(3) 
	note("+ p < .1, * p < .05, ** p < .01, *** p < .001", size(vsmall))
	plotregion(fcolor(white)) graphregion(fcolor(white));
	#delimit cr
	graph export "$main/figures/figure-a8-appendix.pdf", replace

	graph drop A B

****************************************************************************
* CODE FOR FIGURE A.9: DEC 2016 vs JULY 2017 RESULTS FOR WHITES AND BLACKS
****************************************************************************

*Zipcode-level, whites

	use "$main/data/VSG_white_zip.dta", clear
	keep if year == 2016 | year == 2017
	
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)
	
	ta totalmon if monthly_date_confed<tm(2016m12)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_vsg == tm(2017m7) if !missing(monthly_date_vsg)
	
	*treatment period group: monuments removed after December 2016 for 2016 VSG and before July 2017 for 2017 VSG
	*control group: monuments still active after July 2017
	
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2017m1), tm(2017m7))
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2016m12) 
	*also collapsing 
	gen did = pre_post*treated 
	
	*create a line by zipcode year treatment status
	collapse (median) ft_blacks age race liberal conserv educ male, by(id zip state countycode year pre_post treated did)

	gen age2 = age*age

	xtset id year  
	
	sum ft_blacks if year==2016, detail

	quietly eststo zipnocontrolW: reghdfe ft_blacks i.treated##i.pre_post age age2 race liberal conserv educ male, vce(cluster zip) absorb(i.id i.year)
	quietly eststo zipcontrolW: reghdfe ft_blacks i.treated##i.pre_post age age2 race liberal conserv educ male i.state##c.year, vce(cluster zip) absorb(i.id i.year)
		
*Zipcode-level, blacks

	use "$main/data/VSG_black_zip.dta", clear
	keep if year == 2016 | year == 2017
	
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)
	
	ta totalmon if monthly_date_confed<tm(2016m12)
	drop if totalmon==0

	*only depends on time
	gen byte pre_post= monthly_date_vsg == tm(2017m7) if !missing(monthly_date_vsg)
	
	*treatment period group: monuments removed after December 2016 for 2016 CCES and before July 2017 for 2017 CCES
	*control group: monuments still active after July 2017
	
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2017m1), tm(2017m7))
	by zip: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2016m12) 
	*also collapsing 
	gen did = pre_post*treated 
	
	*create a line by zipcode year treatment status
	collapse ft_blacks age race liberal conserv educ male, by(id zip state countycode year pre_post treated did)

	gen age2 = age*age

	xtset id year  
	
	sum ft_blacks if year==2016, detail

	quietly eststo zipnocontrolB: reghdfe ft_blacks i.treated##i.pre_post age age2 race liberal conserv educ male, vce(cluster zip) absorb(i.id i.year)
	quietly eststo zipcontrolB: reghdfe ft_blacks i.treated##i.pre_post age age2 race liberal conserv educ male i.state##c.year, vce(cluster zip) absorb(i.id i.year)

	*graph
	#delimit;
	coefplot 
	(zipnocontrolW, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(zipnocontrolB, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(zipcontrolW, mcolor(gray) ciopts(lcolor(gray) lcol(gray)))
	(zipcontrolB, mcolor(black) ciopts(lcolor(black)) lcol(black)), keep(1.treated#1.pre_post) 
	xline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white)) 
	mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "+", "")))))
	xlab(-.4(0.1).7, nogrid) msymbol(d) mfcolor(white) legend(order(1 "Whites" 3 "Blacks") ring(0) position(3) bmargin(large) size(vsmall) col(1))
	ylab("") title("Feeling Thermometer: Warmth toward Blacks", size(medium) color(black));
	#delimit cr
	graph export "$main/figures/figure-a9-appendix.pdf", replace

****************************************************************************
* CODE FOR FIGURE A.10: DEC 2016 vs JULY 2017 RESULTS FOR WHITES AND BLACKS
****************************************************************************
	set more off
	
*Whites
		
	local geo_level "fivemiles tenmiles twentymiles fiftymiles seventyfivemiles onehundredmiles" 
	local n_models: word count `geo_level'
	
	forval i=1/`n_models' {

	***************
	* GLOBALS	 *
	***************	
	
	global geo_level `: word `i' of `geo_level''

	use "$main/data/CCES_full_${geo_level}.dta", clear

	keep if year == 2014 | year == 2015
	
	egen tag = tag(countycode Unique_ID) 
	egen totalmon = total(tag), by(countycode)

	ta totalmon if monthly_date_confed<tm(2015m7)
	
	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015

	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)
	
	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
	keep if white ==1

	collapse (median) symbolic_index affirm percent_black percent_college med_hh_income percent_white logpop, by(zip state year region countycode pre_post treated did)
	
	xtset zip year  
	
	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post
	
	local regressions = 1 
	if `regressions' {
	quietly eststo affirmw_$geo_level: reghdfe affirm i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo rrw_$geo_level: reghdfe symbolic_index i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 


		}	
}

*Blacks

local geo_level "fivemiles tenmiles twentymiles fiftymiles seventyfivemiles onehundredmiles" 
local n_models: word count `geo_level'

forval i=1/`n_models' {

	***************
	* GLOBALS	 *
	***************	
	
	global geo_level `: word `i' of `geo_level''

	use "$main/data/CCES_full_${geo_level}.dta", clear

	keep if year == 2014 | year == 2015
	
	egen tag = tag(countycode Unique_ID) 
	egen totalmon = total(tag), by(countycode)

	ta totalmon if monthly_date_confed<tm(2015m7)
	
	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015

	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)
	
	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
	keep if white ==0

	collapse (median) symbolic_index affirm percent_black percent_college med_hh_income percent_white logpop, by(zip state year region countycode pre_post treated did)
	
	xtset zip year  
	
	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post
	
	local regressions = 1 
	if `regressions' {
	quietly eststo affirmnw_$geo_level: reghdfe affirm i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 
	quietly eststo rrnw_$geo_level: reghdfe symbolic_index i.treated##i.pre_post black_post college_post white_post income_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip i.year) 


		}	
}

	*graph
	#delimit;
	coefplot (rrw_fivemiles, mcolor(gray) ciopts(lcolor(gray)) lcol(gray)) 
	(rrnw_fivemiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(rrw_tenmiles, mcolor(gray) ciopts(lcolor(gray)) lcol(gray)) 
	(rrnw_tenmiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(rrw_twentymiles, mcolor(gray) ciopts(lcolor(gray)) lcol(gray)) 
	(rrnw_twentymiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(rrw_fiftymiles, mcolor(gray) ciopts(lcolor(gray)) lcol(gray)) 
	(rrnw_fiftymiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(rrw_seventyfivemiles, mcolor(gray) ciopts(lcolor(gray)) lcol(gray)) 
	(rrnw_seventyfivemiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(rrw_onehundredmiles, mcolor(gray) ciopts(lcolor(gray)) lcol(gray))
	(rrnw_onehundredmiles, mcolor(black) ciopts(lcolor(black)) lcol(black)), keep(1.treated#1.pre_post)
	legend(order(1 "Whites" 3 "Blacks") ring(0) position(1) bmargin(large) size(small) col(1)) mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "+", "")))))
	vertical drop(1.treated 1.pre_post _cons) yline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white))
	ytitle("Diff-in-Diff Coefficients" " ", size(small))
	title("Racial Resentment", size(medium) color(black))
	lcol(black)
	ylab(-.5(0.1).6, nogrid) xlabel("") name(C);
	#delimit cr

	#delimit;
	coefplot (affirmw_fivemiles, mcolor(gray) ciopts(lcolor(gray)) lcol(gray)) 
	(affirmnw_fivemiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(affirmw_tenmiles, mcolor(gray) ciopts(lcolor(gray)) lcol(gray)) 
	(affirmnw_tenmiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(affirmw_twentymiles, mcolor(gray) ciopts(lcolor(gray)) lcol(gray)) 
	(affirmnw_twentymiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(affirmw_fiftymiles, mcolor(gray) ciopts(lcolor(gray)) lcol(gray)) 
	(affirmnw_fiftymiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(affirmw_seventyfivemiles, mcolor(gray) ciopts(lcolor(gray)) lcol(gray)) 
	(affirmnw_seventyfivemiles, mcolor(black) ciopts(lcolor(black)) lcol(black)) 
	(affirmw_onehundredmiles, mcolor(gray) ciopts(lcolor(gray)) lcol(gray))
	(affirmnw_onehundredmiles, mcolor(black) ciopts(lcolor(black)) lcol(black)),  keep(1.treated#1.pre_post)
	legend(order(1 "Whites" 3 "Blacks") ring(0) position(1) bmargin(large) size(small) col(1)) mlabposition(1)
	mlabposition(1)
	mlabel(cond(@pval<.001, "***", cond(@pval<.01, "**", cond(@pval<.05, "*", cond(@pval<.1, "+", "")))))
	vertical drop(1.treated 1.pre_post _cons) yline(0, lcolor(black) lwidth(thin) lpattern(dash)) 
	plotregion(fcolor(white)) graphregion(fcolor(white))
	ytitle("" " ")
	title("Support for Affirmative Action", size(medium) color(black))
	lcol(black)
	ylab(-.5(0.1).6, nogrid) xlabel("") name(D);
	#delimit cr

	#delimit;
	graph combine C D, xsize(8) rows(1) cols(2) 
	note("+ p < .1, * p < .05, ** p < .01, *** p < .001", size(vsmall))
	plotregion(fcolor(white)) graphregion(fcolor(white));
	#delimit cr
	graph export "$main/figures/figure-a10-appendix.pdf", replace

	graph drop C D
		
*************************************************************************
* CODE FOR TABLE A17: EFFECT OF REMOVALS FOR NOV 2014 VS DEC 2015 (CCES)
*************************************************************************

	use "$main/data/CCES_full_zip_with_blm.dta", clear

	*only include zipcodes that had at least one monument at start of first treatment period (Nov, 2014)
	keep if year == 2014 | year == 2015
		
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0
	
	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2015m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after November 2014 for 2014 CCES and before Dec 2015 for 2015 CCES
	*control group: monuments still active after December 2015
	
	bysort zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)
	
	drop if monthly_date_confed<=tm(2014m2)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm religion_important percent_black percent_college med_hh_income percent_white logpop had_blm, by(zip state year region countycode pre_post treated did)
	
	xtset zip year 
	by zip, sort: egen obs = count(year)
	drop if obs <2
	drop obs

	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post
	gen had_blm_post = had_blm*pre_post

	sum symbolic_index if year==2014, detail
	*0.61 mean, median of 0.63 [mean of dependent variable is reported in table]
	sum affirm if year==2014, detail
	*0.43 mean, median of 0.43 [mean of dependent variable is reported in table]

	*generate the interaction term 
	gen treated_prepost = treated*pre_post

	*regressions
	quietly eststo zipRR: reghdfe symbolic_index treated pre_post treated_prepost black_post income_post college_post white_post pop_post had_blm_post i.state##c.year, vce(cluster zip) absorb(i.zip)
	quietly eststo zipAA: reghdfe affirm treated pre_post treated_prepost black_post income_post college_post white_post pop_post had_blm_post i.state##c.year, vce(cluster zip) absorb(i.zip)

	esttab zipRR zipAA using "$main/tables/table-a17.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

*************************************************************************
* CODE FOR TABLE A18: EFFECT OF REMOVALS FOR DEC 2018 VS DEC 2020 (CCES)
*************************************************************************

set more off
*county-level

	use "$main/data/CCES_full_county_updated-post2019_with_blm.dta", clear
	
	*only include counties that had at least one monument at start of first treatment period 
	keep if year == 2018 | year == 2019 | year == 2020	
	
egen tag = tag(countycode Unique_ID) 
egen totalmon = total(tag), by(countycode)

	*2018 CES date: Nov-Dec-2018
	*2020 CES date: fielded Nov-Dec 2020
	
ta totalmon if monthly_date_confed<tm(2019m1)
*none with zero monuments at the start of Nov 2018 so don't drop any counties from sample

	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2020m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after Dec 2018 for 2018 CCES and before Dec 2020 for 2020 CCES
	*control group: monuments still active after December 2020
	
	bysort countycode: gen byte removed = inrange(monthly_date_confed, tm(2019m1), tm(2020m11))
	by countycode: egen treated = max(removed)

	drop if monthly_date_confed<=tm(2018m1)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm religion_important Black_Pop logpop DemVote12 had_blm, by(state year region countycode pre_post treated did)

	xtset countycode year  
	by countycode, sort: egen obs = count(year)
	drop if obs <2
	drop obs
	
	*need to interact covariates with post-treatment indicator
	gen black_post = Black_Pop*pre_post
	gen Dem_post = DemVote12*pre_post
	gen pop_post = logpop*pre_post
	gen had_blm_post = had_blm*pre_post

	sum symbolic_index if year==2018, detail
	*0.61 mean, median of 0.62 [mean of dependent variable reported in Table]
	*no affirmative action measures for this year

	*generate the interaction term 
	gen treated_prepost = treated*pre_post

	*Regressions
	quietly eststo countyRR1: reghdfe symbolic_index treated pre_post treated_prepost black_post pop_post Dem_post, vce(cluster countycode) absorb(i.countycode i.year)
	quietly eststo countyRR2: reghdfe symbolic_index treated pre_post treated_prepost black_post pop_post Dem_post i.state##c.year, vce(cluster countycode) absorb(i.countycode)
	quietly eststo countyRR3: reghdfe symbolic_index treated pre_post treated_prepost black_post pop_post Dem_post  had_blm_post i.state##c.year, vce(cluster countycode) absorb(i.countycode)

	esttab countyRR1 countyRR2 countyRR3 using "$main/tables/tablea18-county.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

*zipcode-level

	use "$main/data/CCES_full_zip_updated-post2019_with_blm.dta", clear

	*2018-2020 CES data
	keep if year == 2018 | year == 2020	
		
	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)

	ta totalmon if monthly_date_confed<tm(2019m1)
	drop if totalmon==0
	
	*only depends on time
	gen byte pre_post= monthly_date_cces == tm(2020m12) if !missing(monthly_date_cces)
	
	*treatment period group: monuments removed after Dec 2018 for 2018 CCES and before Dec 2020 for 2020 CCES
	*control group: monuments still active after December 2020
			
	bysort zip: gen byte removed = inrange(monthly_date_confed,  tm(2019m1), tm(2020m11))
	
	*at least ONE of the monuments removed so label all rows with that zipcode as treated 
	by zip: egen treated = max(removed)
	
	drop if monthly_date_confed<=tm(2018m1)
	gen did = pre_post*treated 
	
	gen logpop = log(pop2010) 
	
	collapse symbolic_index affirm religion_important percent_black percent_college med_hh_income percent_white logpop had_blm, by(zip state year region countycode pre_post treated did)
	
	xtset zip year 
	by zip, sort: egen obs = count(year)
	drop if obs <2
	drop obs

	*need to interact covariates with post-treatment indicator
	gen black_post = percent_black*pre_post
	gen white_post = percent_white*pre_post
	gen college_post = percent_college*pre_post
	gen income_post = med_hh_income*pre_post
	gen pop_post = logpop*pre_post
	gen had_blm_post = had_blm*pre_post

	sum symbolic_index if year==2018, detail
	*0.55 mean, median of 0.57 [mean of dependent variable reported in table]
	*no affirmative action measures these years

	*generate the interaction term 
	gen treated_prepost = treated*pre_post

	*regressions:
	quietly eststo zipRR1: reghdfe symbolic_index treated pre_post treated_prepost black_post income_post college_post white_post pop_post, vce(cluster zip) absorb(i.zip i.year)
	quietly eststo zipRR2: reghdfe symbolic_index treated pre_post treated_prepost black_post income_post college_post white_post pop_post i.state##c.year, vce(cluster zip) absorb(i.zip)
	quietly eststo zipRR3: reghdfe symbolic_index treated pre_post treated_prepost black_post income_post college_post white_post pop_post had_blm_post i.state##c.year, vce(cluster zip) absorb(i.zip)

	esttab zipRR1 zipRR2 zipRR3 using "$main/tables/tablea18-zip.txt", cells("b se p ci_l ci_u") stats(r2_a N) keep(treated_prepost) replace

*************************************************************************
* CODE FOR FIGURE A.11: RAW PARALLEL TRENDS, COUNTY-LEVEL HATE CRIME
*************************************************************************

	use "$main/data/FBI_full_county.dta", clear
	drop if year <2010

	egen tag = tag(countycode Unique_ID) 
	egen totalmon = total(tag), by(countycode)
	
	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0
	by countycode: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m10))
	by countycode: egen treated = max(removed)

	gen byte pre_post= inrange(monthly_date_fbi, tm(2015m1), tm(2015m12))
	
	gen did = pre_post*treated 
	
	collapse total_hc_pc, by(treated year)
	
	#delimit ; 
	graph twoway (connected total_hc_pc year if treated==0, lcolor(black) msymbol(o) mcolor(black))|| 
	(connected total_hc_pc year if treated==1, lcolor(gs12) msymbol(oh) mcolor(gs12)),
	plotregion(fcolor(white)) graphregion(fcolor(white)) ylab(0(0.2)2, nogrid) xlab(2010(1)2016, nogrid)
	legend(ring(0) position(1) bmargin(large) label(1 "treated") label(2 "control") size(small)) title("County-level, all offenders", size(medium)) 
	xtitle("") ytitle("Hate Crime, per 100,000" " ") xline(2015, lpattern(dash)) name(A);	
	#delimit cr
	
	*white-offenders
	use "$main/data/FBI_white_offender_county.dta", clear
	drop if year <2010
	
	egen tag = tag(countycode Unique_ID) 
	egen totalmon = total(tag), by(countycode)
	
	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0
	
	by countycode: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m10))
	by countycode: egen treated = max(removed)

	gen byte pre_post= inrange(monthly_date_fbi, tm(2015m1), tm(2015m12))
	
	gen did = pre_post*treated 
	
	collapse total_hc_pc, by(treated year)
	
	#delimit ; 
	graph twoway (connected total_hc_pc year if treated==0, lcolor(black) msymbol(o) mcolor(black))|| 
	(connected total_hc_pc year if treated==1, lcolor(gs12) msymbol(oh) mcolor(gs12)),
	plotregion(fcolor(white)) graphregion(fcolor(white)) ylab(0(0.2)2, nogrid) xlab(2010(1)2016, nogrid)
	legend(ring(0) position(1) bmargin(large) label(1 "treated") label(2 "control") size(small)) title("County-level, white offenders", size(medium))
	xtitle("") ytitle("Hate Crime, per 100,000" " ") xline(2015, lpattern(dash)) name(B);	
	#delimit cr
	
	#delimit;
	graph combine A B, xsize(8) rows(1) cols(2) 
	plotregion(fcolor(white)) graphregion(fcolor(white));
	#delimit cr
	graph export "$main/figures/figure-a11-appendix.pdf", replace

	graph drop A B 

*************************************************************************
* CODE FOR FIGURE A.12: RAW PARALLEL TRENDS, ZIP-LEVEL HATE CRIME
*************************************************************************

	use "$main/data/FBI_full_zip.dta", clear
	drop if year <2010

	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)
	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0
	
	by zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m10))
	by zip: egen treated = max(removed)

	gen byte pre_post= inrange(monthly_date_fbi, tm(2015m1), tm(2015m12)) 	
	gen did = pre_post*treated 
	
	collapse total_hc_pc, by(treated year)
	
	#delimit ; 
	graph twoway (connected total_hc_pc year if treated==0, lcolor(black) msymbol(o) mcolor(black))|| 
	(connected total_hc_pc year if treated==1, lcolor(gs12) msymbol(oh) mcolor(gs12)),
	plotregion(fcolor(white)) graphregion(fcolor(white)) ylab(0(20)200, nogrid) xlab(2010(1)2016, nogrid)
	legend(ring(0) position(1) bmargin(large) label(1 "treated") label(2 "control") size(small)) title("Zipcode-level, all offenders", size(medium))
	xtitle("") ytitle("Hate Crime, per 10,000" " ") xline(2015, lpattern(dash)) name(C);	
	#delimit cr
	
	*zipcode, white-offenders
	
	use "$main/data/FBI_white_offender_zip.dta", clear
	drop if year <2010

	egen tag = tag(zip Unique_ID) 
	egen totalmon = total(tag), by(zip)
	ta totalmon if monthly_date_confed<tm(2015m7)
	drop if totalmon==0
	
	by zip: gen byte removed = inrange(monthly_date_confed, tm(2015m7), tm(2015m10))
	by zip: egen treated = max(removed)

	gen byte pre_post= inrange(monthly_date_fbi, tm(2015m1), tm(2015m12)) 	
	gen did = pre_post*treated 
	
	collapse total_hc_pc, by(treated year)
	
	#delimit ; 
	graph twoway (connected total_hc_pc year if treated==0, lcolor(black) msymbol(o) mcolor(black))|| 
	(connected total_hc_pc year if treated==1, lcolor(gs12) msymbol(oh) mcolor(gs12)),
	plotregion(fcolor(white)) graphregion(fcolor(white)) ylab(0(20)200, nogrid) xlab(2010(1)2016, nogrid)
	legend(ring(0) position(1) bmargin(large) label(1 "treated") label(2 "control") size(small)) title("Zipcode-level, white offenders", size(medium))
	xtitle("") ytitle("Hate Crime, per 10,000" " ") xline(2015, lpattern(dash)) name(D);	
	#delimit cr

	#delimit;
	graph combine C D, xsize(8) rows(1) cols(2) 
	plotregion(fcolor(white)) graphregion(fcolor(white));
	#delimit cr
	graph export "$main/figures/figure-a12-appendix.pdf", replace

	graph drop C D 










